lib/loopdev: remove test program

All is already covered by losetup and mount. The test program has
never been used in our regression tests.

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2014-11-04 15:36:05 +01:00
parent 0bf037402a
commit 9cf4f90911
2 changed files with 0 additions and 154 deletions

View File

@ -62,7 +62,6 @@ check_PROGRAMS += test_cpuset
endif
check_PROGRAMS += \
test_sysfs \
test_loopdev \
test_pager
endif
@ -106,10 +105,6 @@ test_sysfs_LDADD = libcommon.la
test_pager_SOURCES = lib/pager.c
test_pager_CFLAGS = -DTEST_PROGRAM
test_loopdev_SOURCES = lib/loopdev.c
test_loopdev_CFLAGS = -DTEST_PROGRAM_LOOPDEV
test_loopdev_LDADD = libcommon.la
endif
test_fileutils_SOURCES = lib/fileutils.c

View File

@ -1570,152 +1570,3 @@ int loopdev_count_by_backing_file(const char *filename, char **loopdev)
return count;
}
#ifdef TEST_PROGRAM_LOOPDEV
#include <errno.h>
#include <err.h>
static void test_loop_info(const char *device, int flags, int debug)
{
struct loopdev_cxt lc;
char *p;
uint64_t u64;
if (loopcxt_init(&lc, flags))
return;
if (loopcxt_set_device(&lc, device))
err(EXIT_FAILURE, "failed to set device");
p = loopcxt_get_backing_file(&lc);
printf("\tBACKING FILE: %s\n", p);
free(p);
if (loopcxt_get_offset(&lc, &u64) == 0)
printf("\tOFFSET: %jd\n", u64);
if (loopcxt_get_sizelimit(&lc, &u64) == 0)
printf("\tSIZE LIMIT: %jd\n", u64);
printf("\tAUTOCLEAR: %s\n", loopcxt_is_autoclear(&lc) ? "YES" : "NOT");
loopcxt_deinit(&lc);
}
static void test_loop_scan(int flags, int debug)
{
struct loopdev_cxt lc;
int rc;
if (loopcxt_init(&lc, 0))
return;
if (loopcxt_init_iterator(&lc, flags))
err(EXIT_FAILURE, "iterator initlization failed");
while((rc = loopcxt_next(&lc)) == 0) {
const char *device = loopcxt_get_device(&lc);
if (flags & LOOPITER_FL_USED) {
char *backing = loopcxt_get_backing_file(&lc);
printf("\t%s: %s\n", device, backing);
free(backing);
} else
printf("\t%s\n", device);
}
if (rc < 0)
err(EXIT_FAILURE, "loopdevs scanning failed");
loopcxt_deinit(&lc);
}
static int test_loop_setup(const char *filename, const char *device, int debug)
{
struct loopdev_cxt lc;
int rc;
rc = loopcxt_init(&lc, 0);
if (rc)
return rc;
if (device) {
rc = loopcxt_set_device(&lc, device);
if (rc)
err(EXIT_FAILURE, "failed to set device: %s", device);
}
do {
if (!device) {
rc = loopcxt_find_unused(&lc);
if (rc)
err(EXIT_FAILURE, "failed to find unused device");
printf("Trying to use '%s'\n", loopcxt_get_device(&lc));
}
if (loopcxt_set_backing_file(&lc, filename))
err(EXIT_FAILURE, "failed to set backing file");
rc = loopcxt_setup_device(&lc);
if (rc == 0)
break; /* success */
if (device || rc != -EBUSY)
err(EXIT_FAILURE, "failed to setup device for %s",
lc.filename);
printf("device stolen...trying again\n");
} while (1);
loopcxt_deinit(&lc);
return 0;
}
int main(int argc, char *argv[])
{
int dbg;
if (argc < 2)
goto usage;
dbg = getenv("LOOPDEV_DEBUG") == NULL ? 0 : 1;
if (argc == 3 && strcmp(argv[1], "--info") == 0) {
printf("---sysfs & ioctl:---\n");
test_loop_info(argv[2], 0, dbg);
printf("---sysfs only:---\n");
test_loop_info(argv[2], LOOPDEV_FL_NOIOCTL, dbg);
printf("---ioctl only:---\n");
test_loop_info(argv[2], LOOPDEV_FL_NOSYSFS, dbg);
} else if (argc == 2 && strcmp(argv[1], "--used") == 0) {
printf("---all used devices---\n");
test_loop_scan(LOOPITER_FL_USED, dbg);
} else if (argc == 2 && strcmp(argv[1], "--free") == 0) {
printf("---all free devices---\n");
test_loop_scan(LOOPITER_FL_FREE, dbg);
} else if (argc >= 3 && strcmp(argv[1], "--setup") == 0) {
test_loop_setup(argv[2], argv[3], dbg);
} else if (argc == 3 && strcmp(argv[1], "--delete") == 0) {
if (loopdev_delete(argv[2]))
errx(EXIT_FAILURE, "failed to deinitialize device %s", argv[2]);
} else
goto usage;
return EXIT_SUCCESS;
usage:
errx(EXIT_FAILURE, "usage: \n"
" %1$s --info <device>\n"
" %1$s --free\n"
" %1$s --used\n"
" %1$s --setup <filename> [<device>]\n"
" %1$s --delete\n",
argv[0]);
}
#endif /* TEST_PROGRAM */