[gnome-settings-daemon] housekeeping: Create test program for bug 730223



commit 82c91ff6f929a534e26cb70dbd35d344847feb44
Author: Bastien Nocera <hadess hadess net>
Date:   Fri May 16 16:39:26 2014 +0200

    housekeeping: Create test program for bug 730223
    
    $ mkdir /tmp/gsd-purge-temp-test
    $ mkdir /tmp/important/
    $ touch /tmp/important/dont-delete.txt
    $ ln -s /tmp/important/ /tmp/gsd-purge-temp-test/
    $ ls -l /tmp/gsd-purge-temp-test/
    0 lrwxrwxrwx. 1 hadess hadess 15 May 16 16:41 important -> /tmp/important/
    $ ./gsd-purge-temp-test
    <ctrl+c>
    $ ls -l /tmp/gsd-purge-temp-test/
    total 0
    $ ls -l /tmp/important/
    total 0

 plugins/housekeeping/Makefile.am           |   12 +++++-
 plugins/housekeeping/gsd-purge-temp-test.c |   60 ++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/plugins/housekeeping/Makefile.am b/plugins/housekeeping/Makefile.am
index 8469185..1d21571 100644
--- a/plugins/housekeeping/Makefile.am
+++ b/plugins/housekeeping/Makefile.am
@@ -8,7 +8,7 @@ COMMON_FILES =                          \
        gsd-disk-space-helper.h         \
        gsd-disk-space-helper.c
 
-noinst_PROGRAMS = gsd-disk-space-test gsd-empty-trash-test
+noinst_PROGRAMS = gsd-disk-space-test gsd-empty-trash-test gsd-purge-temp-test
 
 gsd_disk_space_test_SOURCES =          \
        gsd-disk-space-test.c           \
@@ -30,6 +30,16 @@ gsd_empty_trash_test_CFLAGS =                \
        $(LIBNOTIFY_CFLAGS)             \
        $(AM_CFLAGS)
 
+gsd_purge_temp_test_SOURCES =          \
+       gsd-purge-temp-test.c           \
+       $(COMMON_FILES)
+gsd_purge_temp_test_LDADD = $(SETTINGS_PLUGIN_LIBS) $(GIOUNIX_LIBS) $(LIBNOTIFY_LIBS)
+gsd_purge_temp_test_CFLAGS =           \
+       $(SETTINGS_PLUGIN_CFLAGS)       \
+       $(GIOUNIX_CFLAGS)               \
+       $(LIBNOTIFY_CFLAGS)             \
+       $(AM_CFLAGS)
+
 libexec_PROGRAMS = gsd-test-housekeeping
 
 gsd_test_housekeeping_SOURCES =                \
diff --git a/plugins/housekeeping/gsd-purge-temp-test.c b/plugins/housekeeping/gsd-purge-temp-test.c
new file mode 100644
index 0000000..2e78932
--- /dev/null
+++ b/plugins/housekeeping/gsd-purge-temp-test.c
@@ -0,0 +1,60 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * vim: set et sw=8 ts=8:
+ *
+ * Copyright (c) 2008, Novell, Inc.
+ *
+ * Authors: Vincent Untz <vuntz gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "config.h"
+#include <gtk/gtk.h>
+#include <libnotify/notify.h>
+#include "gsd-disk-space.h"
+
+int
+main (int    argc,
+      char **argv)
+{
+        GFile *file;
+        DeleteData *data;
+        GDateTime *old;
+        GMainLoop *loop;
+
+        g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+
+        gtk_init (&argc, &argv);
+        notify_init ("gsd-purge-temp-test");
+        loop = g_main_loop_new (NULL, FALSE);
+
+        file = g_file_new_for_path ("/tmp/gsd-purge-temp-test");
+        if (!g_file_query_exists (file, NULL)) {
+                g_warning ("Create /tmp/gsd-purge-temp-test and add some files to it to test deletion by 
date");
+                g_object_unref (file);
+                return 1;
+        }
+
+        old = g_date_time_new_now_local ();
+        data = delete_data_new (file, NULL, old, FALSE, FALSE, 0);
+        delete_recursively_by_age (data);
+        delete_data_unref (data);
+        g_object_unref (file);
+
+        g_main_loop_run (loop);
+
+        return 0;
+}
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]