@@ -32,9 +32,9 @@ int cmd_bat(int argc, const char **argv, struct ndctl_ctx *ctx)
usage_with_options(u, options);
if (force)
- test = ndctl_test_new(UINT_MAX);
+ test = ndctl_test_new(UINT_MAX, argv[0]);
else
- test = ndctl_test_new(0);
+ test = ndctl_test_new(0, argv[0]);
if (!test) {
fprintf(stderr, "failed to initialize test\n");
@@ -42,9 +42,9 @@ int cmd_test(int argc, const char **argv, struct ndctl_ctx *ctx)
usage_with_options(u, options);
if (force)
- test = ndctl_test_new(UINT_MAX);
+ test = ndctl_test_new(UINT_MAX, argv[0]);
else
- test = ndctl_test_new(0);
+ test = ndctl_test_new(0, argv[0]);
if (!test)
return EXIT_FAILURE;
@@ -6,7 +6,7 @@
struct ndctl_test;
struct ndctl_ctx;
-struct ndctl_test *ndctl_test_new(unsigned int kver);
+struct ndctl_test *ndctl_test_new(unsigned int kver, const char *testname);
int ndctl_test_result(struct ndctl_test *test, int rc);
int ndctl_test_get_skipped(struct ndctl_test *test);
int ndctl_test_get_attempted(struct ndctl_test *test);
@@ -23,7 +23,7 @@ struct kmod_module;
int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
struct ndctl_ctx *nd_ctx, int log_level,
struct ndctl_test *test);
-int ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod,
+void ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod,
struct ndctl_ctx *nd_ctx);
struct ndctl_ctx;
@@ -118,7 +118,7 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test,
int main(int argc, char *argv[])
{
char *test_env = getenv("NDCTL_TEST_FAMILY");
- struct ndctl_test *test = ndctl_test_new(0);
+ struct ndctl_test *test = ndctl_test_new(0, argv[0]);
struct ndctl_ctx *ctx;
int rc;
@@ -35,6 +35,16 @@ if [ ! -v NDCTL_TEST_FAMILY ]; then
export NDCTL_TEST_FAMILY=INTEL
fi
+if [ -f "$(dirname $0)/skip_${NDCTL_TEST_FAMILY}.js" ]; then
+ length=$(cat $(dirname $0)/skip_${NDCTL_TEST_FAMILY}.js |\
+ sed 's|//.*||' | jq length)
+ for (( i=0; i<length; i++ )); do
+ test=$(cat $(dirname $0)/skip_${NDCTL_TEST_FAMILY}.js |\
+ sed 's|//.*||' | jq -e -r ".[${i}]")
+ [ "$test" == "${0##*/}" ] && exit 77;
+ done
+fi
+
# NFIT_TEST_BUS[01]
#
NFIT_TEST_BUS0="nfit_test.0"
@@ -7,6 +7,8 @@
#include <errno.h>
#include <stdio.h>
#include <test.h>
+#include <unistd.h>
+#include <json-c/json.h>
#include <util/log.h>
#include <util/sysfs.h>
@@ -39,9 +41,67 @@ static unsigned int get_system_kver(void)
return KERNEL_VERSION(a,b,c);
}
-struct ndctl_test *ndctl_test_new(unsigned int kver)
+static bool skip_current_test(char *skip_file, const char *curtest)
+{
+ FILE *fp;
+ char buffer[16384]; //16k large enough for file with comments
+ const char *curtestname = basename(curtest);
+ struct json_object *skip_array;
+ struct json_object *test;
+ const char *testname;
+ size_t i, size;
+
+ fp = fopen(skip_file, "r");
+ if (fp == NULL) {
+ fprintf(stderr, "Failed to open the %s file. Ignore, and continue..\n", skip_file);
+ return false;
+ }
+
+ size = fread(buffer, 1, 16384, fp);
+ if (size == 0) {
+ fprintf(stderr, "Failed to read the %s file. Ignore, and continue..\n", skip_file);
+ return false;
+ }
+ fclose(fp);
+
+ skip_array = json_tokener_parse(buffer);
+ if (json_object_get_type(skip_array) != json_type_array) {
+ fprintf(stderr, "Failed to parse the %s file. Ignore, and continue..\n", skip_file);
+ return false;
+ }
+
+ for (i = 0; i < json_object_array_length(skip_array); i++) {
+ test = json_object_array_get_idx(skip_array, i);
+ testname = json_object_get_string(test);
+ if (testname && strcmp(curtestname, testname) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+struct ndctl_test *ndctl_test_new(unsigned int kver, const char *testpath)
{
struct ndctl_test *test = calloc(1, sizeof(*test));
+ const char *data_path = getenv("DATA_PATH");
+ const char *test_family = getenv("NDCTL_TEST_FAMILY");
+ char *skip_file = NULL;
+
+ if (test_family && data_path &&
+ (asprintf(&skip_file, "%s/skip_%s.js", data_path, test_family) < 0)) {
+ fprintf(stderr, "test : allocation failed\n");
+ free(test);
+ return NULL;
+ }
+
+ if (skip_file &&
+ (access(skip_file, F_OK) == 0) &&
+ skip_current_test(skip_file, testpath)) {
+ fprintf(stderr, "test : skip requested in the skip_%s.js\n",
+ test_family);
+ ndctl_test_skip(test);
+ exit(ndctl_test_result(test, 77));
+ }
if (!test)
return NULL;
@@ -118,7 +118,7 @@ static int emit_e820_device(int loglevel, struct ndctl_test *test)
int __attribute__((weak)) main(int argc, char *argv[])
{
- struct ndctl_test *test = ndctl_test_new(0);
+ struct ndctl_test *test = ndctl_test_new(0, argv[0]);
int rc;
if (!test) {
@@ -358,7 +358,7 @@ err_mmap:
int __attribute__((weak)) main(int argc, char *argv[])
{
- struct ndctl_test *test = ndctl_test_new(0);
+ struct ndctl_test *test = ndctl_test_new(0, argv[0]);
int fd, rc;
if (!test) {
@@ -423,7 +423,7 @@ static int test_device_dax(int loglevel, struct ndctl_test *test,
int __attribute__((weak)) main(int argc, char *argv[])
{
- struct ndctl_test *test = ndctl_test_new(0);
+ struct ndctl_test *test = ndctl_test_new(0, argv[0]);
struct ndctl_ctx *ctx;
int rc;
@@ -364,7 +364,7 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
int __attribute__((weak)) main(int argc, char *argv[])
{
- struct ndctl_test *test = ndctl_test_new(0);
+ struct ndctl_test *test = ndctl_test_new(0, argv[0]);
struct ndctl_ctx *ctx;
int rc;
@@ -2618,7 +2618,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
int __attribute__((weak)) main(int argc, char *argv[])
{
- struct ndctl_test *test = ndctl_test_new(0);
+ struct ndctl_test *test = ndctl_test_new(0, argv[0]);
struct ndctl_ctx *ctx;
int rc;
@@ -9,6 +9,7 @@ libndctl_deps = [
daxctl_dep,
uuid,
kmod,
+ json,
]
ndctl_deps = libndctl_deps + [
@@ -251,7 +251,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,
int __attribute__((weak)) main(int argc, char *argv[])
{
- struct ndctl_test *test = ndctl_test_new(0);
+ struct ndctl_test *test = ndctl_test_new(0, argv[0]);
struct ndctl_ctx *ctx;
int rc;
@@ -124,7 +124,7 @@ out_devmem:
int main(int argc, char *argv[])
{
- struct ndctl_test *test = ndctl_test_new(0);
+ struct ndctl_test *test = ndctl_test_new(0, argv[0]);
struct ndctl_ctx *ctx;
int rc;
new file mode 100644
@@ -0,0 +1,34 @@
+// List of tests to be skipped on ndtest
+//
+// Append new test cases to this array below until support is added on ndtest.
+//
+["clear.sh", // No error injection support on PPC.
+ "daxdev-errors.sh", // ""
+ "inject-error.sh", // ""
+ "pfn-meta-errors.sh", // ""
+ "pmem-errors.sh", // ""
+ "btt-errors.sh", // ""
+ "label-compat.sh", // Legacy namespace support test/irrelavent on
+ // ndtest.
+ "security.sh", // No support on PPC yet.
+ "daxctl-create.sh", // Depends on dax_hmem
+ "sub-section.sh", // Tests using nd_e820, either duplication when
+ // running on INTEL host, or cannot be tested on
+ // PPC host.
+ "dax-dev", // ""
+ "device-dax", // ""
+ "device-dax-fio.sh", // ""
+ "dax-ext4.sh", // ""
+ "dax-xfs.sh", // ""
+ "daxctl-devices.sh", // ""
+ "revoke_devmem", // ""
+ "align.sh", // ""
+ "dm.sh", // ""
+ "mmap.sh", // ""
+ "monitor.sh", // To be fixed
+ "inject-smart.sh", // ""
+ "libndctl" // ""
+]
+
+// NOTE: The libjson-c doesn't like comments in json files, so keep the file
+// extension as .js to pacify.