/* * Create a debugfs representation of test suites: * * Path Semantics * /sys/kernel/debug/kunit/<testsuite>/results Show results of last run for * testsuite * /sys/kernel/debug/kunit/<testsuite>/run Write to this file to trigger * testsuite to run *
*/
/* * Walk the fragments so we don't need to allocate a temporary * buffer to hold the entire string.
*/
spin_lock(&log->lock);
list_for_each_entry(frag_container, &log->fragments, node)
seq_printf(seq, "%s", frag_container->fragment);
spin_unlock(&log->lock);
}
/* Print KTAP header so the debugfs log can be parsed as valid KTAP. */
seq_puts(seq, "KTAP version 1\n");
seq_puts(seq, "1..1\n");
/* Print suite header because it is not stored in the test logs. */
seq_puts(seq, KUNIT_SUBTEST_INDENT "KTAP version 1\n");
seq_printf(seq, KUNIT_SUBTEST_INDENT "# Subtest: %s\n", suite->name);
seq_printf(seq, KUNIT_SUBTEST_INDENT "1..%zd\n", kunit_suite_num_test_cases(suite));
/* * Print a usage message to the debugfs "run" file * (/sys/kernel/debug/kunit/<testsuite>/run) if opened.
*/ staticint debugfs_print_run(struct seq_file *seq, void *v)
{ struct kunit_suite *suite = (struct kunit_suite *)seq->private;
seq_puts(seq, "Write to this file to trigger the test suite to run.\n");
seq_printf(seq, "usage: echo \"any string\" > /sys/kernel/debugfs/kunit/%s/run\n",
suite->name); return 0;
}
/* * The debugfs "run" file (/sys/kernel/debug/kunit/<testsuite>/run) * contains no information. Write to the file to trigger the test suite * to run.
*/ staticint debugfs_run_open(struct inode *inode, struct file *file)
{ struct kunit_suite *suite;
/* * Trigger a test suite to run by writing to the suite's "run" debugfs * file found at: /sys/kernel/debug/kunit/<testsuite>/run * * Note: what is written to this file will not be saved.
*/ static ssize_t debugfs_run(struct file *file, constchar __user *buf, size_t count, loff_t *ppos)
{ struct inode *f_inode = file->f_inode; struct kunit_suite *suite = (struct kunit_suite *) f_inode->i_private;
/* If suite log already allocated, do not create new debugfs files. */ if (suite->log) return;
/* * Allocate logs before creating debugfs representation. * The suite->log and test_case->log pointer are expected to be NULL * if there isn't a log, so only set it if the log stream was created * successfully.
*/
stream = alloc_string_stream(GFP_KERNEL); if (IS_ERR(stream)) return;
/* Do not create file to re-run test if test runs on init */ if (!suite->is_init) {
debugfs_create_file(KUNIT_DEBUGFS_RUN, S_IFREG | 0644,
suite->debugfs,
suite, &debugfs_run_fops);
} return;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.