X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=tests%2Fopkg_hash_test.c;h=6c67e594dbb68bb8766c77cf0ad5668341a68a7e;hp=7d4ea9686866a39368738b698940294d93af387f;hb=980cfb2e931935a2bd34addccd073811ad1db8e7;hpb=06d63167c8aefc168f4fa774908323e556e6a4e9 diff --git a/tests/opkg_hash_test.c b/tests/opkg_hash_test.c index 7d4ea96..6c67e59 100644 --- a/tests/opkg_hash_test.c +++ b/tests/opkg_hash_test.c @@ -23,57 +23,68 @@ 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); - } + 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); + + } } - - fputs("", stdout); - - } - } - } + } - pkg_hash_deinit(hash); + pkg_hash_deinit(hash); - return 0; + return 0; }