mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Add linux ztest support
Minor changes to ztest for this environment. These including updating ztest to run in the local development tree, as well as relocating some local variables in this function to the heap. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
+25
-24
@@ -4900,32 +4900,30 @@ static void
|
|||||||
ztest_run_zdb(char *pool)
|
ztest_run_zdb(char *pool)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
char zdb[MAXPATHLEN + MAXNAMELEN + 20];
|
|
||||||
char zbuf[1024];
|
|
||||||
char *bin;
|
char *bin;
|
||||||
char *ztest;
|
char *zdb;
|
||||||
char *isa;
|
char *zbuf;
|
||||||
int isalen;
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
(void) realpath(getexecname(), zdb);
|
bin = umem_alloc(MAXPATHLEN + MAXNAMELEN + 20, UMEM_NOFAIL);
|
||||||
|
zdb = umem_alloc(MAXPATHLEN + MAXNAMELEN + 20, UMEM_NOFAIL);
|
||||||
|
zbuf = umem_alloc(1024, UMEM_NOFAIL);
|
||||||
|
|
||||||
/* zdb lives in /usr/sbin, while ztest lives in /usr/bin */
|
VERIFY(realpath(getexecname(), bin) != NULL);
|
||||||
bin = strstr(zdb, "/usr/bin/");
|
if (strncmp(bin, "/usr/sbin/ztest", 14) == 0) {
|
||||||
ztest = strstr(bin, "/ztest");
|
strcpy(bin, "/usr/sbin/zdb"); /* Installed */
|
||||||
isa = bin + 8;
|
} else {
|
||||||
isalen = ztest - isa;
|
strstr(bin, "/ztest/")[0] = '\0'; /* In-tree */
|
||||||
isa = strdup(isa);
|
strcat(bin, "/zdb/zdb");
|
||||||
/* LINTED */
|
}
|
||||||
(void) sprintf(bin,
|
|
||||||
"/usr/sbin%.*s/zdb -bcc%s%s -U %s %s",
|
(void) sprintf(zdb,
|
||||||
isalen,
|
"%s -bcc%s%s -U %s %s",
|
||||||
isa,
|
bin,
|
||||||
zopt_verbose >= 3 ? "s" : "",
|
zopt_verbose >= 3 ? "s" : "",
|
||||||
zopt_verbose >= 4 ? "v" : "",
|
zopt_verbose >= 4 ? "v" : "",
|
||||||
spa_config_path,
|
spa_config_path,
|
||||||
pool);
|
pool);
|
||||||
free(isa);
|
|
||||||
|
|
||||||
if (zopt_verbose >= 5)
|
if (zopt_verbose >= 5)
|
||||||
(void) printf("Executing %s\n", strstr(zdb, "zdb "));
|
(void) printf("Executing %s\n", strstr(zdb, "zdb "));
|
||||||
@@ -4939,13 +4937,17 @@ ztest_run_zdb(char *pool)
|
|||||||
status = pclose(fp);
|
status = pclose(fp);
|
||||||
|
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
return;
|
goto out;
|
||||||
|
|
||||||
ztest_dump_core = 0;
|
ztest_dump_core = 0;
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
fatal(0, "'%s' exit code %d", zdb, WEXITSTATUS(status));
|
fatal(0, "'%s' exit code %d", zdb, WEXITSTATUS(status));
|
||||||
else
|
else
|
||||||
fatal(0, "'%s' died with signal %d", zdb, WTERMSIG(status));
|
fatal(0, "'%s' died with signal %d", zdb, WTERMSIG(status));
|
||||||
|
out:
|
||||||
|
umem_free(bin, MAXPATHLEN + MAXNAMELEN + 20);
|
||||||
|
umem_free(zdb, MAXPATHLEN + MAXNAMELEN + 20);
|
||||||
|
umem_free(zbuf, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -5423,11 +5425,9 @@ ztest_run(ztest_shared_t *zs)
|
|||||||
kernel_fini();
|
kernel_fini();
|
||||||
|
|
||||||
list_destroy(&zcl.zcl_callbacks);
|
list_destroy(&zcl.zcl_callbacks);
|
||||||
|
mutex_destroy(&zcl.zcl_callbacks_lock);
|
||||||
(void) _mutex_destroy(&zcl.zcl_callbacks_lock);
|
rw_destroy(&zs->zs_name_lock);
|
||||||
|
mutex_destroy(&zs->zs_vdev_lock);
|
||||||
(void) rwlock_destroy(&zs->zs_name_lock);
|
|
||||||
(void) _mutex_destroy(&zs->zs_vdev_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -5602,6 +5602,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
ztest_random_fd = open("/dev/urandom", O_RDONLY);
|
ztest_random_fd = open("/dev/urandom", O_RDONLY);
|
||||||
|
|
||||||
|
dprintf_setup(&argc, argv);
|
||||||
process_options(argc, argv);
|
process_options(argc, argv);
|
||||||
|
|
||||||
/* Override location of zpool.cache */
|
/* Override location of zpool.cache */
|
||||||
|
|||||||
Reference in New Issue
Block a user