opkg: move tests into a separate directory
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 04:38:19 +0000 (04:38 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 04:38:19 +0000 (04:38 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@34 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

Makefile.am
configure.ac
libopkg/Makefile.am
libopkg/opkg_extract_test.c [deleted file]
libopkg/opkg_hash_test.c [deleted file]
tests/Makefile.am [new file with mode: 0644]
tests/opkg_extract_test.c [new file with mode: 0644]
tests/opkg_hash_test.c [new file with mode: 0644]

index 69b61f0..07de343 100644 (file)
@@ -1,5 +1,4 @@
-#SUBDIRS = etc replace familiar libbb
-SUBDIRS =  etc familiar libbb libopkg src
+SUBDIRS =  etc familiar libbb libopkg tests src
 
 HOST_CPU=@host_cpu@
 BUILD_CPU=@build_cpu@
index c98db77..d36fa5f 100644 (file)
@@ -129,6 +129,7 @@ AC_SUBST(opkglibdir)
 AC_OUTPUT(
     Makefile
     libopkg/Makefile
+    tests/Makefile
     src/Makefile
     etc/Makefile
     familiar/Makefile
index ad4de4d..a780825 100644 (file)
@@ -63,14 +63,3 @@ libopkg_la_CFLAGS = -DOPKG_LIB $(ALL_CFLAGS)  $(CURL_CFLAGS) $(GPGME_CFLAGS)
 lib_LTLIBRARIES = libopkg.la
 
 
-noinst_PROGRAMS = opkg_hash_test opkg_extract_test
-
-opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.la
-opkg_hash_test_SOURCES = opkg_hash_test.c $(opkg_db_sources) $(opkg_util_sources) $(opkg_list_sources)
-opkg_hash_test_CFLAGS = $(ALL_CFLAGS)
-
-opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.la
-opkg_extract_test_SOURCES = opkg_extract_test.c $(opkg_db_sources) $(opkg_util_sources) $(opkg_list_sources)
-opkg_extract_test_CFLAGS = $(ALL_CFLAGS)
-
-
diff --git a/libopkg/opkg_extract_test.c b/libopkg/opkg_extract_test.c
deleted file mode 100644 (file)
index 83e23e3..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "libbb/libbb.h"
-
-/*
- * build thus: 
-
- * gcc -o opkg_extract_test opkg_extract_test.c -I./busybox-0.60.2/libbb -L./busybox-0.60.2 -lbb
- *
- */
-const char * applet_name;
-
-int main(int argc, char * argv[])
-{
-  /*
-   * see libbb.h and let your imagination run wild
-   * or, set the last item below to extract_one_to_buffer, and you get the control file in 
-   * "returned"
-   * or, set the last one to extract_all_to_fs, and, well, guess what happens
-   */
-
-    /* enum extract_functions_e dowhat = extract_control_tar_gz | extract_unconditional | extract_one_to_buffer; */
-    enum extract_functions_e dowhat = extract_control_tar_gz | extract_all_to_fs | extract_preserve_date;
-  char * returned;
-  char * filename;
-  
-  if(argc < 2){
-    fprintf(stderr, "syntax: %s <opkg file> [<file_to_extract>]\n", argv[0]);
-    exit(0);
-  }
-  
-  if (argc < 3){
-    filename=NULL;
-  } else {
-    filename = argv[2];
-  }
-
-  returned = deb_extract(argv[1], stdout, dowhat, NULL, filename);
-  
-  if(returned)
-    fprintf(stderr, "returned %s\n", returned);
-  else
-    fprintf(stderr, "extract returned nuthin'\n");
-
-  return 0;
-}
diff --git a/libopkg/opkg_hash_test.c b/libopkg/opkg_hash_test.c
deleted file mode 100644 (file)
index 934dac7..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* opkg_hash_test.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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, 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.
-*/
-
-#include "opkg.h"
-
-#include "hash_table.h"
-#include "opkg_utils.h"
-#include "pkg_hash.h"
-
-int main(int argc, char *argv[])
-{
-     opkg_conf_t conf;
-     hash_table_t *hash = &conf.pkg_hash;
-     pkg_vec_t * pkg_vec;
-
-    if (argc < 3) {
-       fprintf(stderr, "Usage: %s <pkgs_file1> <pkgs_file2> [pkg_name...]\n", argv[0]);
-       exit(1);
-    }
-    pkg_hash_init("test", hash, 1024);
-
-    pkg_hash_add_from_file(&conf, argv[1], NULL, NULL, 0);
-    pkg_hash_add_from_file(&conf, argv[2], NULL, NULL, 0);
-
-    if (argc < 4) {
-       pkg_print_info( pkg_hash_fetch_by_name_version(hash, "libc6", "2.2.3-2"), stdout);
-       /*      for(i = 0; i < pkg_vec->len; i++)
-               pkg_print(pkg_vec->pkgs[i], stdout);
-       */
-    } else {
-       int i, j, k;
-       char **unresolved;
-
-       pkg_vec_t * dep_vec;
-       for (i = 3; i < argc; i++) {
-           pkg_vec = pkg_vec_fetch_by_name(hash, argv[i]);
-           if (pkg_vec == NULL) {
-               fprintf(stderr, "*** WARNING: Unknown package: %s\n\n", argv[i]);
-               continue;
-           }
-
-           for(j = 0; j < pkg_vec->len; j++){
-               pkg_print_info(pkg_vec->pkgs[j], stdout);
-               dep_vec = pkg_vec_alloc();
-               pkg_hash_fetch_unsatisfied_dependencies(&conf,
-                                                       pkg_vec->pkgs[j],
-                                                       dep_vec,
-                                                       &unresolved);
-               if(dep_vec){
-                   fprintf(stderr, "and the unsatisfied dependencies are:\n");
-                   for(k = 0; k < dep_vec->len; k++){
-                       fprintf(stderr, "%s version %s\n", dep_vec->pkgs[k]->name, dep_vec->pkgs[k]->version);
-                   }
-               }
-               
-               fputs("", stdout);
-               
-           }
-       }
-    }
-
-    pkg_hash_deinit(hash);
-
-    return 0;
-}
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..f7be7ff
--- /dev/null
@@ -0,0 +1,12 @@
+
+noinst_PROGRAMS = opkg_hash_test opkg_extract_test
+
+opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
+opkg_hash_test_SOURCES = opkg_hash_test.c
+opkg_hash_test_CFLAGS = $(ALL_CFLAGS) -I$(top_builddir)
+
+opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
+opkg_extract_test_SOURCES = opkg_extract_test.c
+opkg_extract_test_CFLAGS = $(ALL_CFLAGS) -I$(top_builddir)
+
+
diff --git a/tests/opkg_extract_test.c b/tests/opkg_extract_test.c
new file mode 100644 (file)
index 0000000..83e23e3
--- /dev/null
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "libbb/libbb.h"
+
+/*
+ * build thus: 
+
+ * gcc -o opkg_extract_test opkg_extract_test.c -I./busybox-0.60.2/libbb -L./busybox-0.60.2 -lbb
+ *
+ */
+const char * applet_name;
+
+int main(int argc, char * argv[])
+{
+  /*
+   * see libbb.h and let your imagination run wild
+   * or, set the last item below to extract_one_to_buffer, and you get the control file in 
+   * "returned"
+   * or, set the last one to extract_all_to_fs, and, well, guess what happens
+   */
+
+    /* enum extract_functions_e dowhat = extract_control_tar_gz | extract_unconditional | extract_one_to_buffer; */
+    enum extract_functions_e dowhat = extract_control_tar_gz | extract_all_to_fs | extract_preserve_date;
+  char * returned;
+  char * filename;
+  
+  if(argc < 2){
+    fprintf(stderr, "syntax: %s <opkg file> [<file_to_extract>]\n", argv[0]);
+    exit(0);
+  }
+  
+  if (argc < 3){
+    filename=NULL;
+  } else {
+    filename = argv[2];
+  }
+
+  returned = deb_extract(argv[1], stdout, dowhat, NULL, filename);
+  
+  if(returned)
+    fprintf(stderr, "returned %s\n", returned);
+  else
+    fprintf(stderr, "extract returned nuthin'\n");
+
+  return 0;
+}
diff --git a/tests/opkg_hash_test.c b/tests/opkg_hash_test.c
new file mode 100644 (file)
index 0000000..934dac7
--- /dev/null
@@ -0,0 +1,79 @@
+/* opkg_hash_test.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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, 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.
+*/
+
+#include "opkg.h"
+
+#include "hash_table.h"
+#include "opkg_utils.h"
+#include "pkg_hash.h"
+
+int main(int argc, char *argv[])
+{
+     opkg_conf_t conf;
+     hash_table_t *hash = &conf.pkg_hash;
+     pkg_vec_t * pkg_vec;
+
+    if (argc < 3) {
+       fprintf(stderr, "Usage: %s <pkgs_file1> <pkgs_file2> [pkg_name...]\n", argv[0]);
+       exit(1);
+    }
+    pkg_hash_init("test", hash, 1024);
+
+    pkg_hash_add_from_file(&conf, argv[1], NULL, NULL, 0);
+    pkg_hash_add_from_file(&conf, argv[2], NULL, NULL, 0);
+
+    if (argc < 4) {
+       pkg_print_info( pkg_hash_fetch_by_name_version(hash, "libc6", "2.2.3-2"), stdout);
+       /*      for(i = 0; i < pkg_vec->len; i++)
+               pkg_print(pkg_vec->pkgs[i], stdout);
+       */
+    } else {
+       int i, j, k;
+       char **unresolved;
+
+       pkg_vec_t * dep_vec;
+       for (i = 3; i < argc; i++) {
+           pkg_vec = pkg_vec_fetch_by_name(hash, argv[i]);
+           if (pkg_vec == NULL) {
+               fprintf(stderr, "*** WARNING: Unknown package: %s\n\n", argv[i]);
+               continue;
+           }
+
+           for(j = 0; j < pkg_vec->len; j++){
+               pkg_print_info(pkg_vec->pkgs[j], stdout);
+               dep_vec = pkg_vec_alloc();
+               pkg_hash_fetch_unsatisfied_dependencies(&conf,
+                                                       pkg_vec->pkgs[j],
+                                                       dep_vec,
+                                                       &unresolved);
+               if(dep_vec){
+                   fprintf(stderr, "and the unsatisfied dependencies are:\n");
+                   for(k = 0; k < dep_vec->len; k++){
+                       fprintf(stderr, "%s version %s\n", dep_vec->pkgs[k]->name, dep_vec->pkgs[k]->version);
+                   }
+               }
+               
+               fputs("", stdout);
+               
+           }
+       }
+    }
+
+    pkg_hash_deinit(hash);
+
+    return 0;
+}