Apparantly my previous patch is in error, as: 1) test/ isn't even used anymore, but it is still present in git for who knows what reason, and 2) the build system is not currently smart enough to regenerate configure and the Makefiles when Makefile.am changes. Signed-off-by: Dan McGee <dan@xxxxxxxxxxxxx> --- test/.gitignore | 14 --- test/test-blacklist.c | 76 ----------------- test/test-elf.c | 106 ----------------------- test/test-get-dependencies.c | 52 ------------ test/test-init.c | 23 ----- test/test-insmod.c | 52 ------------ test/test-invalidate-config.c | 49 ----------- test/test-loaded.c | 63 -------------- test/test-lookup.c | 184 ----------------------------------------- test/test-mod-double-ref.c | 78 ----------------- test/test-path-from-name.c | 48 ----------- test/test-probe.c | 118 -------------------------- test/test-rmmod.c | 57 ------------- test/test-rmmod2.c | 44 ---------- test/test-state.c | 49 ----------- 15 files changed, 0 insertions(+), 1013 deletions(-) delete mode 100644 test/.gitignore delete mode 100644 test/test-blacklist.c delete mode 100644 test/test-elf.c delete mode 100644 test/test-get-dependencies.c delete mode 100644 test/test-init.c delete mode 100644 test/test-insmod.c delete mode 100644 test/test-invalidate-config.c delete mode 100644 test/test-loaded.c delete mode 100644 test/test-lookup.c delete mode 100644 test/test-mod-double-ref.c delete mode 100644 test/test-path-from-name.c delete mode 100644 test/test-probe.c delete mode 100644 test/test-rmmod.c delete mode 100644 test/test-rmmod2.c delete mode 100644 test/test-state.c delete mode 100644 test/test.conf diff --git a/test/.gitignore b/test/.gitignore deleted file mode 100644 index d959b6d..0000000 --- a/test/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -/.dirstamp -/test-blacklist -/test-elf -/test-get-dependencies -/test-init -/test-insmod -/test-invalidate-config -/test-loaded -/test-lookup -/test-mod-double-ref -/test-path-from-name -/test-probe -/test-rmmod -/test-rmmod2 diff --git a/test/test-blacklist.c b/test/test-blacklist.c deleted file mode 100644 index a53c902..0000000 --- a/test/test-blacklist.c +++ /dev/null @@ -1,76 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - const char *alias; - struct kmod_ctx *ctx; - struct kmod_list *list = NULL, *l; - int err; - - printf("libkmod version %s\n", VERSION); - - if (argc < 2) { - fprintf(stderr, "ERR: Provide an alias name\n"); - return EXIT_FAILURE; - } - - alias = argv[1]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - exit(EXIT_FAILURE); - - err = kmod_module_new_from_lookup(ctx, alias, &list); - if (err < 0) - goto fail_lookup; - - if (list == NULL) - printf("No module matches '%s'\n", alias); - else - printf("Alias: '%s'\nModules matching:\n", alias); - - kmod_list_foreach(l, list) { - struct kmod_module *mod = kmod_module_get_module(l); - printf("\t%s\n", kmod_module_get_name(mod)); - kmod_module_unref(mod); - } - - if (list != NULL) { - struct kmod_list *filtered; - err = kmod_module_get_filtered_blacklist(ctx, list, &filtered); - if (err < 0) { - printf("Could not filter: %s\n", strerror(-err)); - goto fail; - } - if (filtered == NULL) - printf("All modules were filtered out!\n"); - else - printf("Modules remaining after filter:\n"); - - kmod_list_foreach(l, filtered) { - struct kmod_module *mod = kmod_module_get_module(l); - printf("\t%s\n", kmod_module_get_name(mod)); - kmod_module_unref(mod); - } - kmod_module_unref_list(filtered); - } - - kmod_module_unref_list(list); - kmod_unref(ctx); - - return EXIT_SUCCESS; - -fail: - kmod_module_unref_list(list); -fail_lookup: - kmod_unref(ctx); - return EXIT_FAILURE; -} diff --git a/test/test-elf.c b/test/test-elf.c deleted file mode 100644 index 23dd1fd..0000000 --- a/test/test-elf.c +++ /dev/null @@ -1,106 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> -#include <getopt.h> - -int main(int argc, char *argv[]) -{ - struct kmod_ctx *ctx; - struct kmod_module *mod; - struct kmod_list *list, *l; - int err; - - printf("libkmod version %s\n", VERSION); - - if (argc != 2) { - fprintf(stderr, "Usage:\n\t%s <module-path.ko>\n", argv[0]); - return EXIT_FAILURE; - } - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - return EXIT_FAILURE; - - err = kmod_module_new_from_path(ctx, argv[1], &mod); - if (err < 0) { - fprintf(stderr, "ERROR: could not load %s: %s\n", - argv[1], strerror(-errno)); - goto module_error; - } - - list = NULL; - err = kmod_module_get_info(mod, &list); - if (err <= 0) - printf("no information! (%s)\n", strerror(-err)); - else { - puts("info:"); - kmod_list_foreach(l, list) { - const char *key, *val; - key = kmod_module_info_get_key(l); - val = kmod_module_info_get_value(l); - printf("\t%s: %s\n", key, val ? val : ""); - } - kmod_module_info_free_list(list); - } - - list = NULL; - err = kmod_module_get_versions(mod, &list); - if (err <= 0) - printf("no modversions! (%s)\n", strerror(-err)); - else { - puts("modversions:"); - kmod_list_foreach(l, list) { - const char *symbol; - uint64_t crc; - symbol = kmod_module_version_get_symbol(l); - crc = kmod_module_version_get_crc(l); - printf("\t%s: %#"PRIx64"\n", symbol, crc); - } - kmod_module_versions_free_list(list); - } - - list = NULL; - err = kmod_module_get_symbols(mod, &list); - if (err <= 0) - printf("no symbols! (%s)\n", strerror(-err)); - else { - puts("symbols:"); - kmod_list_foreach(l, list) { - const char *symbol; - uint64_t crc; - symbol = kmod_module_symbol_get_symbol(l); - crc = kmod_module_symbol_get_crc(l); - printf("\t%s: %#"PRIx64"\n", symbol, crc); - } - kmod_module_symbols_free_list(list); - } - - list = NULL; - err = kmod_module_get_dependency_symbols(mod, &list); - if (err <= 0) - printf("no dependency symbols! (%s)\n", strerror(-err)); - else { - puts("dependency symbols:"); - kmod_list_foreach(l, list) { - const char *symbol; - uint8_t bind; - uint64_t crc; - symbol = kmod_module_dependency_symbol_get_symbol(l); - bind = kmod_module_dependency_symbol_get_bind(l); - crc = kmod_module_dependency_symbol_get_crc(l); - printf("\t%s %c: %#"PRIx64"\n", symbol, bind, crc); - } - kmod_module_dependency_symbols_free_list(list); - } - - kmod_module_unref(mod); -module_error: - kmod_unref(ctx); - - return (err < 0) ? EXIT_FAILURE : EXIT_SUCCESS; -} diff --git a/test/test-get-dependencies.c b/test/test-get-dependencies.c deleted file mode 100644 index 3a7bbf2..0000000 --- a/test/test-get-dependencies.c +++ /dev/null @@ -1,52 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - const char *name; - struct kmod_ctx *ctx; - struct kmod_module *mod; - struct kmod_list *list, *l; - int err; - - printf("libkmod version %s\n", VERSION); - - if (argc < 2) { - fprintf(stderr, "ERR: Provide a module name\n"); - return EXIT_FAILURE; - } - - name = argv[1]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - exit(EXIT_FAILURE); - - err = kmod_module_new_from_name(ctx, name, &mod); - if (err < 0) { - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - list = kmod_module_get_dependencies(mod); - printf("Module: %s\nDependency list:\n", name); - - kmod_list_foreach(l, list) { - struct kmod_module *m = kmod_module_get_module(l); - printf("\t%s\n", kmod_module_get_name(m)); - kmod_module_unref(m); - } - - kmod_module_unref_list(list); - kmod_module_unref(mod); - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test-init.c b/test/test-init.c deleted file mode 100644 index 3128431..0000000 --- a/test/test-init.c +++ /dev/null @@ -1,23 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - struct kmod_ctx *ctx; - const char *null_config = NULL; - - ctx = kmod_new(NULL, &null_config); - if (ctx == NULL) - exit(EXIT_FAILURE); - - printf("libkmod version %s\n", VERSION); - - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test-insmod.c b/test/test-insmod.c deleted file mode 100644 index 7198df0..0000000 --- a/test/test-insmod.c +++ /dev/null @@ -1,52 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - const char *path; - struct kmod_ctx *ctx; - struct kmod_module *mod; - int err; - - if (argc < 2) { - fprintf(stderr, "Provide a path to a module\n"); - return EXIT_FAILURE; - } - - path = argv[1]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - exit(EXIT_FAILURE); - - printf("libkmod version %s\n", VERSION); - - err = kmod_module_new_from_path(ctx, path, &mod); - if (err < 0) { - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - printf("Trying insmod '%s' (%s)\n", kmod_module_get_name(mod), - kmod_module_get_path(mod)); - err = kmod_module_insert_module(mod, 0, NULL); - if (err < 0) { - fprintf(stderr, "%s\n", strerror(-err)); - - kmod_module_unref(mod); - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - kmod_module_unref(mod); - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test-invalidate-config.c b/test/test-invalidate-config.c deleted file mode 100644 index 52370c8..0000000 --- a/test/test-invalidate-config.c +++ /dev/null @@ -1,49 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - -static const char *config[] = { - NULL, - NULL, -}; - -int main(int argc, char *argv[]) -{ - struct kmod_ctx *ctx; - int r; - char cmd[4096]; - - if (argc < 2) { - fprintf(stderr, "Provide a path to config\n"); - return EXIT_FAILURE; - } - - config[0] = argv[1]; - - ctx = kmod_new(NULL, config); - if (ctx == NULL) - exit(EXIT_FAILURE); - - r = kmod_validate_resources(ctx); - if (r != KMOD_RESOURCES_OK) { - fprintf(stderr, "ERR: return should be 'resources ok'\n"); - return EXIT_FAILURE; - } - - snprintf(cmd, sizeof(cmd), "touch %s", config[0]); - system(cmd); - r = kmod_validate_resources(ctx); - if (r != KMOD_RESOURCES_MUST_RECREATE) { - fprintf(stderr, "ERR: return should be 'must recreate'\n"); - return EXIT_FAILURE; - } - - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test-loaded.c b/test/test-loaded.c deleted file mode 100644 index 9d34aa3..0000000 --- a/test/test-loaded.c +++ /dev/null @@ -1,63 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - struct kmod_ctx *ctx; - const char *null_config = NULL; - struct kmod_list *list, *itr; - int err; - - ctx = kmod_new(NULL, &null_config); - if (ctx == NULL) - exit(EXIT_FAILURE); - - printf("libkmod version %s\n", VERSION); - - err = kmod_module_new_from_loaded(ctx, &list); - if (err < 0) { - fprintf(stderr, "%s\n", strerror(-err)); - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - printf("Module Size Used by\n"); - - kmod_list_foreach(itr, list) { - struct kmod_module *mod = kmod_module_get_module(itr); - const char *name = kmod_module_get_name(mod); - int use_count = kmod_module_get_refcnt(mod); - long size = kmod_module_get_size(mod); - struct kmod_list *holders, *hitr; - int first = 1; - - printf("%-19s %8ld %d ", name, size, use_count); - holders = kmod_module_get_holders(mod); - kmod_list_foreach(hitr, holders) { - struct kmod_module *hm = kmod_module_get_module(hitr); - - if (!first) - putchar(','); - else - first = 0; - - fputs(kmod_module_get_name(hm), stdout); - kmod_module_unref(hm); - } - putchar('\n'); - kmod_module_unref_list(holders); - kmod_module_unref(mod); - } - kmod_module_unref_list(list); - - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test-lookup.c b/test/test-lookup.c deleted file mode 100644 index 70cdb5c..0000000 --- a/test/test-lookup.c +++ /dev/null @@ -1,184 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> -#include <getopt.h> - -static const char cmdoptions_short[] = "lh"; -static const struct option cmdoptions[] = { - {"load-resources", no_argument, 0, 'l'}, - {"help", no_argument, 0, 'h'}, - {NULL, 0, 0, 0} -}; - -static void help(const char *progname) -{ - const struct option *itr_opt; - const char *itr_short; - printf("Usage:\n" - "\t%s [options] <name-to-lookup>\n" - "Options:\n", - progname); - for (itr_opt = cmdoptions, itr_short = cmdoptions_short; - itr_opt->name != NULL; itr_opt++, itr_short++) - printf("\t-%c, --%s\n", *itr_short, itr_opt->name); -} - -int main(int argc, char *argv[]) -{ - const char *alias = NULL; - struct kmod_ctx *ctx; - struct kmod_list *list = NULL, *l; - int load_resources = 0; - int err; - - printf("libkmod version %s\n", VERSION); - - for (;;) { - int c, idx = 0; - c = getopt_long(argc, argv, cmdoptions_short, cmdoptions, &idx); - if (c == -1) - break; - switch (c) { - case 'l': - load_resources = 1; - break; - case 'h': - help(argv[0]); - return 0; - case '?': - return -1; - default: - fprintf(stderr, - "ERR: unexpected getopt_long() value %c\n", c); - return -1; - } - } - - if (optind >= argc) { - fprintf(stderr, "ERR: Provide an alias name\n"); - return EXIT_FAILURE; - } - - alias = argv[optind]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) { - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - if (load_resources) { - err = kmod_load_resources(ctx); - if (err < 0) { - printf("Could not load resources: %s\n", - strerror(-err)); - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - } - - err = kmod_module_new_from_lookup(ctx, alias, &list); - if (err < 0) - exit(EXIT_FAILURE); - - if (list == NULL) - printf("No module matches '%s'\n", alias); - else - printf("Alias: '%s'\nModules matching:\n", alias); - - kmod_list_foreach(l, list) { - struct kmod_list *d, *pre = NULL, *post = NULL; - struct kmod_module *mod = kmod_module_get_module(l); - const char *str; - - printf("\t%s\n", kmod_module_get_name(mod)); - str = kmod_module_get_options(mod); - if (str) - printf("\t\toptions: '%s'\n", str); - str = kmod_module_get_install_commands(mod); - if (str) - printf("\t\tinstall commands: '%s'\n", str); - str = kmod_module_get_remove_commands(mod); - if (str) - printf("\t\tremove commands: '%s'\n", str); - - err = kmod_module_get_softdeps(mod, &pre, &post); - if (err == 0) { - if (pre != NULL || post != NULL) - puts("\t\tsoft dependencies:"); - if (pre != NULL) { - fputs("\t\t\tpre:", stdout); - kmod_list_foreach(d, pre) { - struct kmod_module *dm = kmod_module_get_module(d); - printf(" %s", kmod_module_get_name(dm)); - kmod_module_unref(dm); - } - putchar('\n'); - kmod_module_unref_list(pre); - } - if (post != NULL) { - fputs("\t\t\tpost:", stdout); - kmod_list_foreach(d, post) { - struct kmod_module *dm = kmod_module_get_module(d); - printf(" %s", kmod_module_get_name(dm)); - kmod_module_unref(dm); - } - putchar('\n'); - kmod_module_unref_list(post); - } - } - - pre = NULL; - err = kmod_module_get_info(mod, &pre); - if (err > 0) { - puts("\t\tmodinfo:"); - kmod_list_foreach(d, pre) { - const char *key, *val; - key = kmod_module_info_get_key(d); - val = kmod_module_info_get_value(d); - printf("\t\t\t%s: %s\n", key, val ? val : ""); - } - kmod_module_info_free_list(pre); - } - - pre = NULL; - err = kmod_module_get_versions(mod, &pre); - if (err > 0) { - puts("\t\tmodversions:"); - kmod_list_foreach(d, pre) { - const char *symbol; - uint64_t crc; - symbol = kmod_module_version_get_symbol(d); - crc = kmod_module_version_get_crc(d); - printf("\t\t\t%s: %#"PRIx64"\n", symbol, crc); - } - kmod_module_versions_free_list(pre); - } - - pre = NULL; - err = kmod_module_get_symbols(mod, &pre); - if (err > 0) { - puts("\t\tsymbols:"); - kmod_list_foreach(d, pre) { - const char *symbol; - uint64_t crc; - symbol = kmod_module_symbol_get_symbol(d); - crc = kmod_module_symbol_get_crc(d); - printf("\t\t\t%s: %#"PRIx64"\n", symbol, crc); - } - kmod_module_symbols_free_list(pre); - } - - kmod_module_unref(mod); - } - - kmod_module_unref_list(list); - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test-mod-double-ref.c b/test/test-mod-double-ref.c deleted file mode 100644 index 9033247..0000000 --- a/test/test-mod-double-ref.c +++ /dev/null @@ -1,78 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - struct kmod_ctx *ctx; - struct kmod_module *mod1, *mod2; - const char *modname; - int err; - - if (argc < 2) { - fprintf(stderr, "ERR: Provide an alias name\n"); - return EXIT_FAILURE; - } - - modname = argv[1]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - exit(EXIT_FAILURE); - - printf("libkmod version %s\n", VERSION); - - err = kmod_module_new_from_name(ctx, modname, &mod1); - if (err < 0) { - fprintf(stderr, "error creating module: '%s'\n", strerror(-err)); - goto fail; - } - - printf("modname='%s' obj=%p\n", modname, mod1); - - err = kmod_module_new_from_name(ctx, modname, &mod2); - if (err < 0) { - fprintf(stderr, "error creating module: '%s'\n", strerror(-err)); - goto fail; - } - - printf("modname='%s' obj=%p\n", modname, mod2); - - kmod_module_unref(mod1); - kmod_module_unref(mod2); - - /* same thing, but now unref the first module */ - - err = kmod_module_new_from_name(ctx, modname, &mod1); - if (err < 0) { - fprintf(stderr, "error creating module: '%s'\n", strerror(-err)); - goto fail; - } - - printf("modname='%s' obj=%p\n", modname, mod1); - - kmod_module_unref(mod1); - - err = kmod_module_new_from_name(ctx, modname, &mod2); - if (err < 0) { - fprintf(stderr, "error creating module: '%s'\n", strerror(-err)); - goto fail; - } - - printf("modname='%s' obj=%p\n", modname, mod2); - - kmod_module_unref(mod2); - kmod_unref(ctx); - - return EXIT_SUCCESS; - -fail: - kmod_unref(ctx); - return EXIT_FAILURE; -} diff --git a/test/test-path-from-name.c b/test/test-path-from-name.c deleted file mode 100644 index 3f3d568..0000000 --- a/test/test-path-from-name.c +++ /dev/null @@ -1,48 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - struct kmod_ctx *ctx; - struct kmod_module *mod; - const char *path, *modname; - int err; - - if (argc < 2) { - fprintf(stderr, "ERR: Provide an alias name\n"); - return EXIT_FAILURE; - } - - modname = argv[1]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - exit(EXIT_FAILURE); - - printf("libkmod version %s\n", VERSION); - - err = kmod_module_new_from_name(ctx, modname, &mod); - if (err < 0) { - fprintf(stderr, "error creating module: '%s'\n", strerror(-err)); - goto fail; - } - - path = kmod_module_get_path(mod); - - printf("modname: '%s' path: '%s'\n", modname, path); - kmod_module_unref(mod); - kmod_unref(ctx); - - return EXIT_SUCCESS; - -fail: - kmod_unref(ctx); - return EXIT_FAILURE; -} diff --git a/test/test-probe.c b/test/test-probe.c deleted file mode 100644 index c68a783..0000000 --- a/test/test-probe.c +++ /dev/null @@ -1,118 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> -#include <getopt.h> - -static const char cmdoptions_short[] = "lh"; -static const struct option cmdoptions[] = { - {"load-resources", no_argument, 0, 'l'}, - {"help", no_argument, 0, 'h'}, - {NULL, 0, 0, 0} -}; - -static void help(const char *progname) -{ - const struct option *itr_opt; - const char *itr_short; - printf("Usage:\n" - "\t%s [options] <module> [ module_options ]\n" - "Options:\n", - progname); - for (itr_opt = cmdoptions, itr_short = cmdoptions_short; - itr_opt->name != NULL; itr_opt++, itr_short++) - printf("\t-%c, --%s\n", *itr_short, itr_opt->name); -} - -int main(int argc, char *argv[]) -{ - const char *alias; - const char *opt; - struct kmod_ctx *ctx; - struct kmod_list *list = NULL, *l; - int load_resources = 0; - int err; - - printf("libkmod version %s\n", VERSION); - - for (;;) { - int c, idx = 0; - c = getopt_long(argc, argv, cmdoptions_short, cmdoptions, &idx); - if (c == -1) - break; - switch (c) { - case 'l': - load_resources = 1; - break; - case 'h': - help(argv[0]); - return 0; - case '?': - return -1; - default: - fprintf(stderr, - "ERR: unexpected getopt_long() value %c\n", c); - return -1; - } - } - - if (optind >= argc) { - fprintf(stderr, "ERR: Provide an alias name\n"); - return EXIT_FAILURE; - } - - alias = argv[optind++]; - - if (optind < argc) - opt = argv[optind]; - else - opt = NULL; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) { - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - if (load_resources) { - err = kmod_load_resources(ctx); - if (err < 0) { - printf("Could not load resources: %s\n", - strerror(-err)); - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - } - - err = kmod_module_new_from_lookup(ctx, alias, &list); - if (err < 0) - exit(EXIT_FAILURE); - - if (list == NULL) - printf("No module matches '%s'\n", alias); - else - printf("Alias: '%s'\nModules matching:\n", alias); - - kmod_list_foreach(l, list) { - struct kmod_module *mod = kmod_module_get_module(l); - - printf("\t%s", kmod_module_get_name(mod)); - - err = kmod_module_probe_insert_module(mod, 0, opt, NULL, NULL); - if (err >=0 ) - printf(": inserted ok\n"); - else - printf(": failed to insert\n"); - - kmod_module_unref(mod); - } - - kmod_module_unref_list(list); - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test-rmmod.c b/test/test-rmmod.c deleted file mode 100644 index 493af80..0000000 --- a/test/test-rmmod.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - const char *modname = NULL; - const char *null_config = NULL; - struct kmod_ctx *ctx; - struct kmod_list *list, *itr; - int err, count = 0; - - if (argc == 2) - modname = argv[1]; - - ctx = kmod_new(NULL, &null_config); - if (ctx == NULL) - exit(EXIT_FAILURE); - - printf("libkmod version %s\n", VERSION); - - err = kmod_module_new_from_loaded(ctx, &list); - if (err < 0) { - fprintf(stderr, "%s\n", strerror(-err)); - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - kmod_list_foreach(itr, list) { - struct kmod_module *mod = kmod_module_get_module(itr); - const char *name = kmod_module_get_name(mod); - - if ((modname && !strcmp(modname, name)) || - (modname == NULL && kmod_module_get_refcnt(mod) < 1)) { - printf("Trying to remove '%s'\n", name); - err = kmod_module_remove_module(mod, 0); - if (err == 0) - count++; - else { - fprintf(stderr, "Error removing %s: %s\n", - name, strerror(-err)); - } - } - - kmod_module_unref(mod); - } - kmod_module_unref_list(list); - kmod_unref(ctx); - - return count > 0; -} diff --git a/test/test-rmmod2.c b/test/test-rmmod2.c deleted file mode 100644 index 7a7a0ba..0000000 --- a/test/test-rmmod2.c +++ /dev/null @@ -1,44 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - const char *modname = NULL; - struct kmod_ctx *ctx; - struct kmod_module *mod; - int err; - - if (argc < 2) { - fprintf(stderr, "Provide a module name\n"); - return EXIT_FAILURE; - } - - modname = argv[1]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - exit(EXIT_FAILURE); - - printf("libkmod version %s\n", VERSION); - - err = kmod_module_new_from_name(ctx, modname, &mod); - if (err < 0) { - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - printf("Trying to remove '%s'\n", modname); - kmod_module_remove_module(mod, 0); - - kmod_module_unref(mod); - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test-state.c b/test/test-state.c deleted file mode 100644 index b34edfb..0000000 --- a/test/test-state.c +++ /dev/null @@ -1,49 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - const char *name; - struct kmod_ctx *ctx; - struct kmod_module *mod; - int err; - const char *state; - - if (argc < 2) { - fprintf(stderr, "Provide a module name\n"); - return EXIT_FAILURE; - } - - name = argv[1]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - exit(EXIT_FAILURE); - - printf("libkmod version %s\n", VERSION); - - err = kmod_module_new_from_name(ctx, name, &mod); - if (err < 0) { - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - state = kmod_module_initstate_str(kmod_module_get_initstate(mod)); - if (state == NULL) - printf("Module '%s' not found.\n", name); - else - printf("Module '%s' is in '%s' state.\n", name, state); - - - kmod_module_unref(mod); - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/test/test.conf b/test/test.conf deleted file mode 100644 index e69de29..0000000 -- 1.7.9 -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html