From f431cd1a48a6a5186633bf5f16a2d21cb4399e8c Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 09 Feb 2012 10:56:43 -0500 Subject: Initial commit. TODO: Copyright information. Including source code and a patch to add files generated by GNU Autoconf is not very pretty... Running 'make dist' in the SVN trunk to generate a source archive might be better. --- (limited to 'src/tests/.svn') diff --git a/src/tests/.svn/all-wcprops b/src/tests/.svn/all-wcprops new file mode 100644 index 0000000..cf285ed --- /dev/null +++ b/src/tests/.svn/all-wcprops @@ -0,0 +1,35 @@ +K 25 +svn:wc:ra_dav:version-url +V 29 +/svn/!svn/ver/634/trunk/tests +END +opkg_hash_test.c +K 25 +svn:wc:ra_dav:version-url +V 46 +/svn/!svn/ver/552/trunk/tests/opkg_hash_test.c +END +opkg_active_list_test.c +K 25 +svn:wc:ra_dav:version-url +V 53 +/svn/!svn/ver/552/trunk/tests/opkg_active_list_test.c +END +libopkg_test.c +K 25 +svn:wc:ra_dav:version-url +V 44 +/svn/!svn/ver/622/trunk/tests/libopkg_test.c +END +Makefile.am +K 25 +svn:wc:ra_dav:version-url +V 41 +/svn/!svn/ver/474/trunk/tests/Makefile.am +END +opkg_extract_test.c +K 25 +svn:wc:ra_dav:version-url +V 49 +/svn/!svn/ver/552/trunk/tests/opkg_extract_test.c +END diff --git a/src/tests/.svn/entries b/src/tests/.svn/entries new file mode 100644 index 0000000..930a7e8 --- /dev/null +++ b/src/tests/.svn/entries @@ -0,0 +1,201 @@ +10 + +dir +635 +http://opkg.googlecode.com/svn/trunk/tests +http://opkg.googlecode.com/svn + + + +2012-01-19T13:51:59.790020Z +634 +pixdamix@gmail.com + + + + + + + + + + + + + + +e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 + +opkg_hash_test.c +file + + + + +2012-02-03T08:11:57.359042Z +42ded85fe3c9d5d5427ee6f07b629828 +2010-08-18T03:39:02.973664Z +552 +graham.gower + + + + + + + + + + + + + + + + + + + + + +2134 + +opkg_active_list_test.c +file + + + + +2012-02-03T08:11:57.359042Z +3a5506764a10f969300fefc107066e3b +2010-08-18T03:39:02.973664Z +552 +graham.gower + + + + + + + + + + + + + + + + + + + + + +4626 + +libopkg_test.c +file + + + + +2012-02-03T08:11:57.359042Z +e37fec6637c1992e52ec2d4bad07776d +2011-05-26T00:51:50.330823Z +622 +graham.gower@gmail.com + + + + + + + + + + + + + + + + + + + + + +6385 + +Makefile.am +file + + + + +2012-02-03T08:11:57.359042Z +4f0297e9e0f54993a1809827d77b12ae +2009-12-09T06:05:08.329580Z +474 +graham.gower + + + + + + + + + + + + + + + + + + + + + +907 + +regress +dir + +opkg_extract_test.c +file + + + + +2012-02-03T08:11:57.359042Z +ab5ec2fffab9a3b9ab566b56c9ee8d11 +2010-08-18T03:39:02.973664Z +552 +graham.gower + + + + + + + + + + + + + + + + + + + + + +1152 + diff --git a/src/tests/.svn/text-base/Makefile.am.svn-base b/src/tests/.svn/text-base/Makefile.am.svn-base new file mode 100644 index 0000000..1a6f565 --- /dev/null +++ b/src/tests/.svn/text-base/Makefile.am.svn-base @@ -0,0 +1,23 @@ +AM_CFLAGS = $(ALL_CFLAGS) -Wall -g -O3 -I${top_srcdir}/libopkg + +#noinst_PROGRAMS = opkg_hash_test opkg_extract_test +#noinst_PROGRAMS = libopkg_test opkg_active_list_test +noinst_PROGRAMS = libopkg_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_srcdir) + +#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_srcdir) + +#opkg_active_list_test_LDADD = $(top_builddir)/libopkg/active_list.o +#opkg_active_list_test_SOURCES = opkg_active_list_test.c +#opkg_active_list_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir) + +libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.la +libopkg_test_SOURCE = libopkg_test.c +libopkg_test_LDFLAGS = -static + + diff --git a/src/tests/.svn/text-base/libopkg_test.c.svn-base b/src/tests/.svn/text-base/libopkg_test.c.svn-base new file mode 100644 index 0000000..21f100e --- /dev/null +++ b/src/tests/.svn/text-base/libopkg_test.c.svn-base @@ -0,0 +1,261 @@ +#include +#include +#include +#include + +#include + +int opkg_state_changed; +pkg_t *find_pkg = NULL; + + +#define TEST_PACKAGE "aspell" + +void +progress_callback (const opkg_progress_data_t *progress, void *data) +{ + printf ("\r%s %3d%%\n", (char*) data, progress->percentage); + fflush (stdout); +} + +static void list_pkg(pkg_t *pkg) +{ + char *v = pkg_version_str_alloc(pkg); + printf ("%s - %s\n", pkg->name, v); + free(v); +} + +void +package_list_installed_callback (pkg_t *pkg, void *data) +{ + if (pkg->state_status == SS_INSTALLED) + list_pkg(pkg); +} + +void +package_list_callback (pkg_t *pkg, void *data) +{ + static int install_count = 0; + static int total_count = 0; + + if (pkg->state_status == SS_INSTALLED) + install_count++; + + total_count++; + + printf ("\rPackage count: %d Installed, %d Total Available", install_count, total_count); + fflush (stdout); + + if (!find_pkg) + { + /* store the first package to print out later */ + find_pkg = pkg; + } +} + +void +package_list_upgradable_callback (pkg_t *pkg, void *data) +{ + list_pkg(pkg); +} + +void +print_package (pkg_t *pkg) +{ + char *v = pkg_version_str_alloc(pkg); + printf ( + "Name: %s\n" + "Version: %s\n" + "Repository: %s\n" + "Architecture: %s\n" + "Description: %s\n" + "Tags: %s\n" + "Size: %ld\n" + "Status: %d\n", + pkg->name, + v, + pkg->src->name, + pkg->architecture, + pkg->description, + pkg->tags? pkg->tags : "", + pkg->size, + pkg->state_status); + free(v); +} + + +void +opkg_test (void) +{ + int err; + pkg_t *pkg; + + err = opkg_update_package_lists (progress_callback, "Updating..."); + printf ("\nopkg_update_package_lists returned %d\n", err); + + opkg_list_packages (package_list_callback, NULL); + printf ("\n"); + + if (find_pkg) + { + printf ("Finding package \"%s\"\n", find_pkg->name); + pkg = opkg_find_package (find_pkg->name, find_pkg->version, find_pkg->architecture, find_pkg->src->name); + if (pkg) + { + print_package (pkg); + } + else + printf ("Package \"%s\" not found!\n", find_pkg->name); + } + else + printf ("No package available to test find_package.\n"); + + err = opkg_install_package (TEST_PACKAGE, progress_callback, "Installing..."); + printf ("\nopkg_install_package returned %d\n", err); + + err = opkg_upgrade_package (TEST_PACKAGE, progress_callback, "Upgrading..."); + printf ("\nopkg_upgrade_package returned %d\n", err); + + err = opkg_remove_package (TEST_PACKAGE, progress_callback, "Removing..."); + printf ("\nopkg_remove_package returned %d\n", err); + + printf ("Listing upgradable packages...\n"); + opkg_list_upgradable_packages (package_list_upgradable_callback, NULL); + + err = opkg_upgrade_all (progress_callback, "Upgrading all..."); + printf ("\nopkg_upgrade_all returned %d\n", err); + +} + +int +main (int argc, char **argv) +{ + pkg_t *pkg; + int err; + + if (argc < 2) + { + printf ("Usage: %s command\n" + "\nCommands:\n" + "\tupdate - Update package lists\n" + "\tfind [package] - Print details of the specified package\n" + "\tinstall [package] - Install the specified package\n" + "\tupgrade [package] - Upgrade the specified package\n" + "\tlist upgrades - List the available upgrades\n" + "\tlist all - List all available packages\n" + "\tlist installed - List all the installed packages\n" + "\tremove [package] - Remove the specified package\n" + "\trping - Reposiroties ping, check the accessibility of repositories\n" + "\ttest - Run test script\n" + , basename (argv[0])); + exit (0); + } + + setenv("OFFLINE_ROOT", "/tmp", 0); + + if (opkg_new ()) { + printf("opkg_new() failed. This sucks.\n"); + print_error_list(); + return 1; + } + + char *cache; + opkg_set_option("cache", "|asdf|"); + if (opkg_get_option("cache", &cache) != -1) { + printf("cache=``%s''\n", cache); + } + + int verb; + opkg_set_option("verbosity", (void *)3); + if (opkg_get_option("verbosity", &verb) != -1) { + printf("verbosity=%d\n", verb); + } + + switch (argv[1][0]) + { + case 'f': + pkg = opkg_find_package (argv[2], NULL, NULL, NULL); + if (pkg) + { + print_package (pkg); + } + else + printf ("Package \"%s\" not found!\n", find_pkg->name); + break; + case 'i': + err = opkg_install_package (argv[2], progress_callback, "Installing..."); + printf ("\nopkg_install_package returned %d\n", err); + break; + + case 'u': + if (argv[1][2] == 'd') + { + err = opkg_update_package_lists (progress_callback, "Updating..."); + printf ("\nopkg_update_package_lists returned %d\n", err); + break; + } + else + { + if (argc < 3) + { + err = opkg_upgrade_all (progress_callback, "Upgrading all..."); + printf ("\nopkg_upgrade_all returned %d\n", err); + } + else + { + err = opkg_upgrade_package (argv[2], progress_callback, "Upgrading..."); + printf ("\nopkg_upgrade_package returned %d\n", err); + } + } + break; + + case 'l': + if (argc < 3) + { + printf ("Please specify one either all, installed or upgrades\n"); + } + else + { + switch (argv[2][0]) + { + case 'u': + printf ("Listing upgradable packages...\n"); + opkg_list_upgradable_packages (package_list_upgradable_callback, NULL); + break; + case 'a': + printf ("Listing all packages...\n"); + opkg_list_packages (package_list_callback, NULL); + printf ("\n"); + break; + case 'i': + printf ("Listing installed packages...\n"); + opkg_list_packages (package_list_installed_callback, NULL); + break; + default: + printf ("Unknown list option \"%s\"\n", argv[2]); + } + } + break; + + case 'r': + if (argv[1][1] == 'e') + { + err = opkg_remove_package (argv[2], progress_callback, "Removing..."); + printf ("\nopkg_remove_package returned %d\n", err); + break; + }else if (argv[1][1] == 'p') + { + err = opkg_repository_accessibility_check(); + printf("\nopkg_repository_accessibility_check returned (%d)\n", err); + break; + } + + default: + printf ("Unknown command \"%s\"\n", argv[1]); + } + + + opkg_free (); + + return 0; +} diff --git a/src/tests/.svn/text-base/opkg_active_list_test.c.svn-base b/src/tests/.svn/text-base/opkg_active_list_test.c.svn-base new file mode 100644 index 0000000..b6af3b3 --- /dev/null +++ b/src/tests/.svn/text-base/opkg_active_list_test.c.svn-base @@ -0,0 +1,145 @@ +/* opkg_active_list.c - the opkg package management system + + Tick Chen + + Copyright (C) 2008 Openmoko + + 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 +#include +#include +#include + +struct active_test { + char *str; + struct active_list list; +}; + +struct active_test *active_test_new(char *str) { + struct active_test *ans = (struct active_test *)calloc(1, sizeof(struct active_test)); + ans->str = str; + active_list_init(&ans->list); + return ans; +} +void active_test_add(struct active_list *head, struct active_test *node) { + active_list_add(head, &node->list); +} + +void active_test_add_depend(struct active_test *A, struct active_test *B) { + active_list_add_depend(&A->list, &B->list); +} + +/* +.--A---B----C----D-----E----F + | |__k---L + | |_ N + |__ G ---H ---I---J + |_M |_O + +Then the sequence will be ++: G M H I O J A B K N L C D E F +-: F E D C L N K B A J O I H M G +*/ +void make_list(struct active_list *head) { + struct active_test *A = active_test_new("A"); + struct active_test *B = active_test_new("B"); + struct active_test *C = active_test_new("C"); + struct active_test *D = active_test_new("D"); + struct active_test *E = active_test_new("E"); + struct active_test *F = active_test_new("F"); + struct active_test *G = active_test_new("G"); + struct active_test *H = active_test_new("H"); + struct active_test *I = active_test_new("I"); + struct active_test *J = active_test_new("J"); + struct active_test *K = active_test_new("K"); + struct active_test *L = active_test_new("L"); + struct active_test *M = active_test_new("M"); + struct active_test *N = active_test_new("N"); + struct active_test *O = active_test_new("O"); + + active_test_add(head, A); + active_test_add(head, B); + active_test_add(head, C); + active_test_add(head, D); + active_test_add(head, E); + active_test_add(head, F); + active_test_add(head, G); + active_test_add(head, H); + active_test_add(head, I); + active_test_add(head, J); + active_test_add(head, K); + active_test_add(head, L); + active_test_add(head, M); + active_test_add(head, N); + active_test_add(head, O); + active_test_add_depend(H, M); + active_test_add_depend(A, G); + active_test_add_depend(A, H); + active_test_add_depend(A, I); + active_test_add_depend(A, J); + active_test_add_depend(J, O); + active_test_add_depend(C, K); + active_test_add_depend(C, L); + active_test_add_depend(L, N); +} + +int active_test_compare(const void *a, const void *b) { + struct active_list *first = (struct active_list *)a; + struct active_list *second = (struct active_list *)b; + return strcmp(list_entry(first, struct active_test, list), + list_entry(second, struct active_test, list)); +} + +void show_list(struct active_list *head) { + struct active_list *ptr; + struct active_test *test; + for(ptr = active_list_next(head, NULL); ptr ;ptr = active_list_next(head, ptr)) { + test = list_entry(ptr, struct active_test, list); + printf ("%s ",test->str); + } + printf("\n"); +} + +int main (void) { + struct active_list head; + struct active_list *ptr; + struct active_test *test; + active_list_init(&head); + make_list(&head); + + printf("pos order: "); + show_list(&head); +/* for(ptr = active_list_next(&head, &head); ptr ;ptr = active_list_next(&head, ptr)) { + test = list_entry(ptr, struct active_test, list); + printf ("%s ",test->str); + }*/ + printf("neg order: "); + for(ptr = active_list_prev(&head, &head); ptr ;ptr = active_list_prev(&head, ptr)) { + test = list_entry(ptr, struct active_test, list); + printf ("%s ",test->str); + } + printf("\npos order after sort: "); + active_list_sort(&head, &active_test_compare); + show_list(&head); + + printf("after clear: "); + active_list_clear(&head); + for(ptr = active_list_next(&head, NULL); ptr ;ptr = active_list_next(&head, ptr)) { + test = list_entry(ptr, struct active_test, list); + printf ("%s ",test->str); + } + printf("\n"); + + +} diff --git a/src/tests/.svn/text-base/opkg_extract_test.c.svn-base b/src/tests/.svn/text-base/opkg_extract_test.c.svn-base new file mode 100644 index 0000000..9754691 --- /dev/null +++ b/src/tests/.svn/text-base/opkg_extract_test.c.svn-base @@ -0,0 +1,46 @@ +#include +#include +#include + +/* + * 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 []\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/src/tests/.svn/text-base/opkg_hash_test.c.svn-base b/src/tests/.svn/text-base/opkg_hash_test.c.svn-base new file mode 100644 index 0000000..de1d82c --- /dev/null +++ b/src/tests/.svn/text-base/opkg_hash_test.c.svn-base @@ -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 + +#include +#include +#include + +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 [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; +} -- cgit v0.9.1