X-Git-Url: http://git.wpitchoune.net/gitweb/?p=psensor-pkg-ubuntu.git;a=blobdiff_plain;f=tests%2Ftest_io_dir_list.c;fp=tests%2Ftest_io_dir_list.c;h=0000000000000000000000000000000000000000;hp=29a9c31fa053011e74a5199956eed24a3551613e;hb=4487aa672b4ea293173ff44bb76f79fb59bae024;hpb=3a67d56a58c3b1000a8dedb8b783ad7472f66850 diff --git a/tests/test_io_dir_list.c b/tests/test_io_dir_list.c deleted file mode 100644 index 29a9c31..0000000 --- a/tests/test_io_dir_list.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2010-2011 jeanfi@gmail.com - * - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include -#include -#include - -#include "../src/lib/pio.h" - -static int test_empty_dir() -{ - int ret; - char **paths; - - paths = dir_list("data/empty_dir", NULL); - - ret = 0; - if (paths) { - if (*paths) { - ret = 1; - fprintf(stderr, "ERROR: list not empty %s\n", *paths); - } - - paths_free(paths); - } - - return ret; -} - -static int test_2files_dir() -{ - int ret, one, two; - char **paths, **cur; - - paths = dir_list("data/2files_dir", NULL); - - one = two = ret = 0; - - if (!paths) { - fprintf(stderr, "ERROR: list is NULL\n"); - return 1; - } - - cur = paths; - while(*cur) { - if (!strcmp(*cur, "data/2files_dir/one")) { - one++; - } else if (!strcmp(*cur, "data/2files_dir/two")) { - two++; - } else { - fprintf(stderr, "ERROR: wrong item: %s\n", *cur); - - ret = 1; - } - - cur++; - } - - if (!ret && one == 1 && two == 1) - ret = 0; - else - ret = 1; - - paths_free(paths); - - return ret; -} - -static int tests_dir_list() { - int failures; - - failures = test_empty_dir(); - - failures += test_2files_dir(); - - return failures; -} - -int main(int argc, char **argv) -{ - int failures; - - failures = tests_dir_list(); - - if (failures) - exit(EXIT_FAILURE); - else - exit(EXIT_SUCCESS); -}