blob: 45f53d6187e5f96678346836c9adb0e1c14270eb [file] [log] [blame]
/*
* Copyright(c) 2014 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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 <stdio.h>
#include <syslog.h>
#include <test.h>
#include <limits.h>
#include <builtin.h>
#include <util/util.h>
#include <subcmd/parse-options.h>
int cmd_bat(int argc, const char **argv, void *ctx)
{
int loglevel = LOG_DEBUG, i, rc;
struct ndctl_test *test;
bool force = false;
const char * const u[] = {
"ndctl bat [<options>]",
NULL
};
const struct option options[] = {
OPT_INTEGER('l', "loglevel", &loglevel,
"set the log level (default LOG_DEBUG)"),
OPT_BOOLEAN('f', "force", &force,
"force run all tests regardless of required kernel"),
OPT_END(),
};
argc = parse_options(argc, argv, options, u, 0);
for (i = 0; i < argc; i++)
error("unknown parameter \"%s\"\n", argv[i]);
if (argc)
usage_with_options(u, options);
if (force)
test = ndctl_test_new(UINT_MAX);
else
test = ndctl_test_new(0);
if (!test) {
fprintf(stderr, "failed to initialize test\n");
return EXIT_FAILURE;
}
rc = test_blk_namespaces(loglevel, test, ctx);
fprintf(stderr, "test_blk_namespaces: %s\n", rc ? "FAIL" : "PASS");
if (rc && rc != 77)
return rc;
rc = test_pmem_namespaces(loglevel, test, ctx);
fprintf(stderr, "test_pmem_namespaces: %s\n", rc ? "FAIL" : "PASS");
return ndctl_test_result(test, rc);
}