find $(top_srcdir)/src -name \*.c -exec $(srcdir)/checkpatch.pl -q --no-tree -emacs -f {} \;
find $(top_srcdir)/src -name \*.h -exec $(srcdir)/checkpatch.pl -q --no-tree -emacs -f {} \;
-EXTRA_DIST = checkpatch.pl
+EXTRA_DIST = checkpatch.pl data test-io-dir-list.sh
-check_PROGRAMS = test-url-encode test-url-normalize
+check_PROGRAMS = test-io-dir-list \
+ test-url-encode \
+ test-url-normalize
+
+AM_CPPFLAGS = -pedantic
test_url_encode_SOURCES = test_url_encode.c
test_url_encode_LDADD = ../src/lib/libpsensor.a
test_url_normalize_SOURCES = test_url_normalize.c
test_url_normalize_LDADD = ../src/lib/libpsensor.a
+test_io_dir_list_SOURCES = test_io_dir_list.c
+test_io_dir_list_LDADD = ../src/lib/libpsensor.a
+
TESTS = test-url-encode \
- test-url-normalize
\ No newline at end of file
+ test-url-normalize \
+ test-io-dir-list.sh
\ No newline at end of file
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-check_PROGRAMS = test-url-encode$(EXEEXT) test-url-normalize$(EXEEXT)
-TESTS = test-url-encode$(EXEEXT) test-url-normalize$(EXEEXT)
+check_PROGRAMS = test-io-dir-list$(EXEEXT) test-url-encode$(EXEEXT) \
+ test-url-normalize$(EXEEXT)
+TESTS = test-url-encode$(EXEEXT) test-url-normalize$(EXEEXT) \
+ test-io-dir-list.sh
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
+am_test_io_dir_list_OBJECTS = test_io_dir_list.$(OBJEXT)
+test_io_dir_list_OBJECTS = $(am_test_io_dir_list_OBJECTS)
+test_io_dir_list_DEPENDENCIES = ../src/lib/libpsensor.a
am_test_url_encode_OBJECTS = test_url_encode.$(OBJEXT)
test_url_encode_OBJECTS = $(am_test_url_encode_OBJECTS)
test_url_encode_DEPENDENCIES = ../src/lib/libpsensor.a
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(test_url_encode_SOURCES) $(test_url_normalize_SOURCES)
-DIST_SOURCES = $(test_url_encode_SOURCES) \
+SOURCES = $(test_io_dir_list_SOURCES) $(test_url_encode_SOURCES) \
+ $(test_url_normalize_SOURCES)
+DIST_SOURCES = $(test_io_dir_list_SOURCES) $(test_url_encode_SOURCES) \
$(test_url_normalize_SOURCES)
ETAGS = etags
CTAGS = ctags
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-EXTRA_DIST = checkpatch.pl
+EXTRA_DIST = checkpatch.pl data test-io-dir-list.sh
+AM_CPPFLAGS = -pedantic
test_url_encode_SOURCES = test_url_encode.c
test_url_encode_LDADD = ../src/lib/libpsensor.a
test_url_normalize_SOURCES = test_url_normalize.c
test_url_normalize_LDADD = ../src/lib/libpsensor.a
+test_io_dir_list_SOURCES = test_io_dir_list.c
+test_io_dir_list_LDADD = ../src/lib/libpsensor.a
all: all-am
.SUFFIXES:
clean-checkPROGRAMS:
-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
+test-io-dir-list$(EXEEXT): $(test_io_dir_list_OBJECTS) $(test_io_dir_list_DEPENDENCIES)
+ @rm -f test-io-dir-list$(EXEEXT)
+ $(LINK) $(test_io_dir_list_OBJECTS) $(test_io_dir_list_LDADD) $(LIBS)
test-url-encode$(EXEEXT): $(test_url_encode_OBJECTS) $(test_url_encode_DEPENDENCIES)
@rm -f test-url-encode$(EXEEXT)
$(LINK) $(test_url_encode_OBJECTS) $(test_url_encode_LDADD) $(LIBS)
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_io_dir_list.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_url_encode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_url_normalize.Po@am__quote@
--- /dev/null
+#/bin/sh
+
+mkdir -p data/empty_dir
+mkdir -p data/2files_dir
+touch data/2files_dir/one
+touch data/2files_dir/two
+
+./test-io-dir-list || exit 1
+
+rm data/2files_dir/one data/2files_dir/two
+rmdir data/empty_dir data/2files_dir
\ No newline at end of file
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#include <stdio.h>
+
+#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("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 = 0;
+
+ failures += tests_dir_list();
+
+ if (failures)
+ exit(EXIT_FAILURE);
+ else
+ exit(EXIT_SUCCESS);
+}
* 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
+ * 02110-1301 USA
*/
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
* 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
+ * 02110-1301 USA
*/
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../src/lib/url.h"
-
int test_url_normalize(const char *url, const char *ref_url)
{
int ret;
return ret;
}
-
int tests_url_normalize()
{
int failures;