#include <isc/buffer.h>
#include <isc/commandline.h>
+#include <isc/file.h>
#include <isc/hash.h>
#include <isc/log.h>
#include <isc/mem.h>
int
teardown_managers(void **state);
+isc_result_t
+file_path_to_groupname(const char *path, char *out, size_t outlen);
+/*%<
+ * Example:
+ * "/.../tests/dns/dbdiff" -> "dns_dbdiff"
+ *
+ * Returns ISC_R_SUCCESS on success, ISC_R_NOSPACE if outlen is too small,
+ * or other error codes returned by isc_file_splitpath.
+ */
+
#ifndef TESTS_DIR
#define TESTS_DIR "./"
#endif
} \
} \
\
+ char group_name[1024]; \
+ isc_result_t res = file_path_to_groupname(argv[0], group_name, \
+ sizeof(group_name)); \
+ if (res != ISC_R_SUCCESS) { \
+ strncpy(group_name, "tests", sizeof(group_name)); \
+ } \
if (selected[0].name != NULL) { \
- r = cmocka_run_group_tests(selected, setup, teardown); \
+ r = cmocka_run_group_tests_name(group_name, selected, \
+ setup, teardown); \
} else { \
- r = cmocka_run_group_tests(tests, setup, teardown); \
+ r = cmocka_run_group_tests_name(group_name, tests, \
+ setup, teardown); \
} \
\
teardown_mctx(NULL); \
#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/os.h>
+#include <isc/result.h>
#include <isc/string.h>
#include <isc/timer.h>
#include <isc/util.h>
return 0;
}
+
+isc_result_t
+file_path_to_groupname(const char *path, char *out, size_t outlen) {
+ char *dir = NULL;
+ const char *base = NULL;
+ const char *parent_basename;
+ const char *file_basename;
+
+ REQUIRE(path != NULL);
+ REQUIRE(out != NULL);
+
+ RETERR(isc_file_splitpath(isc_g_mctx, path, &dir, &base));
+
+ parent_basename = isc_file_basename(dir);
+ file_basename = isc_file_basename(base);
+
+ if (strlen(parent_basename) + 1 + strlen(file_basename) + 1 > outlen) {
+ isc_mem_free(isc_g_mctx, dir);
+ return ISC_R_NOSPACE;
+ }
+
+ snprintf(out, outlen, "%s_%s", parent_basename, file_basename);
+
+ isc_mem_free(isc_g_mctx, dir);
+ return ISC_R_SUCCESS;
+}