Fix altstack check to work again on OSX with -O2.
[mono-project.git] / eglib / test / dir.c
blobf8711217250b0d4772e55c84d7e805bca61369fe
1 #include <config.h>
2 #include <glib.h>
3 #include <string.h>
4 #include <stdio.h>
5 #ifdef HAVE_UNISTD_H
6 #include <unistd.h>
7 #endif
8 #ifdef G_OS_UNIX
9 #include <pthread.h>
10 #endif
11 #include "test.h"
13 /* This test is just to be used with valgrind */
14 RESULT
15 test_dir ()
17 GDir *dir;
18 GError *error;
19 const gchar *name;
22 dir = g_dir_open (NULL, 0, NULL);
24 dir = g_dir_open ("", 0, NULL);
25 if (dir != NULL)
26 return FAILED ("1 Should be an error");
28 dir = g_dir_open ("", 9, NULL);
29 if (dir != NULL)
30 return FAILED ("2 Should be an error");
32 error = NULL;
33 dir = g_dir_open (".ljasdslakjd", 9, &error);
34 if (dir != NULL)
35 return FAILED ("3 opendir should fail");
36 if (error == NULL)
37 return FAILED ("4 got no error");
38 g_error_free (error);
39 error = NULL;
40 dir = g_dir_open (g_get_tmp_dir (), 9, &error);
41 if (dir == NULL)
42 return FAILED ("5 opendir should succeed");
43 if (error != NULL)
44 return FAILED ("6 got an error");
45 name = NULL;
46 name = g_dir_read_name (dir);
47 if (name == NULL)
48 return FAILED ("7 didn't read a file name");
49 while ((name = g_dir_read_name (dir)) != NULL) {
50 if (strcmp (name, ".") == 0)
51 return FAILED (". directory found");
52 if (strcmp (name, "..") == 0)
53 return FAILED (".. directory found");
55 g_dir_close (dir);
56 return OK;
59 static Test dir_tests [] = {
60 {"g_dir_*", test_dir},
61 {NULL, NULL}
64 DEFINE_TEST_GROUP_INIT(dir_tests_init, dir_tests)