Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 01/10] tools/test-runner: Default to time travel with User Mode Linux
Date: Fri, 30 Oct 2026 17:29:30 -0400	[thread overview]
Message-ID: <20261030212940.753771-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261030212940.753771-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Run User Mode Linux on simulated time whenever the kernel supports it,
since that is what makes the testers fast and their timing reproducible,
and add -R, --real-time, to run it on real time instead. -T now only
makes the lack of time travel support an error.

Do not start a calendar when a time-travel kernel parameter is given
with -o, so guests can join an external calendar shared with other
guests and controllers, as test-functional does.

Assisted-by: Claude:claude-opus-5-5
---
 doc/test-runner.rst | 23 +++++++++++++----------
 tools/test-runner.c | 33 +++++++++++++++++++++++++--------
 2 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/doc/test-runner.rst b/doc/test-runner.rst
index 02d69b06f54c..220a2cec1c55 100644
--- a/doc/test-runner.rst
+++ b/doc/test-runner.rst
@@ -29,7 +29,8 @@ OPTIONS
 :-k/--kernel=<image>: Kernel image (bzImage) or User Mode Linux binary
 :-F/--virtiofs[=<path>]: Path to virtiofsd, or no to disable virtio-fs
 :-T/--time-travel: Run a User Mode Linux kernel on simulated time, with
-    btvirt as time travel calendar
+    btvirt as time travel calendar (default if the kernel supports it)
+:-R/--real-time: Run a User Mode Linux kernel on real time
 :-o/--option=<opt>: Additional argument passed to QEMU, or kernel
     parameter with User Mode Linux
 :-h/--help: Show help options
@@ -152,12 +153,14 @@ Bluetooth controller, or joins an external simulated clock with
 ``time-travel=ext:<socket>``. See `virtio.rst <virtio.rst>`_. ``-u``,
 ``-U``, ``-P``, ``-q`` and ``-H`` need QEMU.
 
-With ``-T``, test-runner starts **btvirt(1)** ``--time`` as time travel
-calendar and runs the guest on its simulated clock: time only advances when
-the guest waits, so it skips idle time and timeouts take no real time, while
-the guest sees the same timings on every run. This needs a kernel with
-``CONFIG_UML_TIME_TRAVEL_SUPPORT``, which test-runner checks; without
-``-T`` the same kernel runs on real time.
+If the kernel has ``CONFIG_UML_TIME_TRAVEL_SUPPORT``, test-runner starts
+**btvirt(1)** ``--time`` as time travel calendar and runs the guest on its
+simulated clock: time only advances when the guest waits, so it skips idle
+time and timeouts take no real time, while the guest sees the same timings
+on every run. ``-R`` runs the guest on real time instead, and ``-T`` fails if
+the kernel has no time travel support. A ``time-travel`` kernel parameter
+given with ``-o``, e.g. to join the calendar of other guests, replaces the
+calendar of test-runner.
 
 Kernel
 ======
@@ -421,9 +424,9 @@ Running mgmt-tester under User Mode Linux
 	$ make ARCH=um olddefconfig linux
 	$ tools/test-runner -k <linux>/linux -- tools/mgmt-tester
 
-On simulated time, with a kernel that also has
-``CONFIG_UML_TIME_TRAVEL_SUPPORT=y``:
+With a kernel that also has ``CONFIG_UML_TIME_TRAVEL_SUPPORT=y`` this runs
+on simulated time; to run it on real time:
 
 .. code-block::
 
-	$ tools/test-runner -T -k <linux>/linux -- tools/mgmt-tester
+	$ tools/test-runner -R -k <linux>/linux -- tools/mgmt-tester
diff --git a/tools/test-runner.c b/tools/test-runner.c
index 8be4bfb09265..b4947f113607 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -66,7 +66,8 @@ static bool start_dbus_session;
 static bool start_daemon = false;
 static bool start_monitor = false;
 static bool qemu_host_cpu = false;
-static bool time_travel;
+/* Simulated time with User Mode Linux: -1 if supported by the kernel */
+static int time_travel = -1;
 static int num_devs = 0;
 static int num_emulator = 0;
 static const char *device_path = "/tmp/bt-server-bredr";
@@ -1224,9 +1225,14 @@ static int start_uml(void)
 	strv_append(&argv, "TESTAUDIO='%s'", audio_server ? audio_server : "");
 	strv_append(&argv, "TESTARGS='%s'", testargs);
 
-	for (i = 0; i < num_extra_opts; ++i)
+	for (i = 0; i < num_extra_opts; ++i) {
 		strv_append(&argv, "%s", extra_opts[i]);
 
+		/* Time travel mode given with -o, e.g. an external calendar */
+		if (!strncmp(extra_opts[i], "time-travel", 11))
+			time_travel = 0;
+	}
+
 	if (time_travel) {
 		calendar = start_calendar(dir);
 		if (calendar < 0)
@@ -2164,6 +2170,8 @@ static void usage(void)
 		"\t-F, --virtiofs[=<path>]  Virtiofsd path or 'no'\n"
 		"\t-T, --time-travel      Run User Mode Linux on simulated\n"
 		"\t                       time, with btvirt as calendar\n"
+		"\t                       (default if supported)\n"
+		"\t-R, --real-time        Run User Mode Linux on real time\n"
 		"\t-o, --option <opt>     Additional argument passed to QEMU,\n"
 		"\t                       or kernel parameter with User\n"
 		"\t                       Mode Linux\n"
@@ -2188,6 +2196,7 @@ static const struct option main_options[] = {
 	{ "option",  required_argument, NULL, 'o' },
 	{ "virtiofs", optional_argument, NULL, 'F' },
 	{ "time-travel", no_argument,   NULL, 'T' },
+	{ "real-time", no_argument,     NULL, 'R' },
 	{ "version", no_argument,       NULL, 'v' },
 	{ "help",    no_argument,       NULL, 'h' },
 	{ }
@@ -2211,8 +2220,9 @@ int main(int argc, char *argv[])
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, "au::bdsl::mq:Hk:A::U:P:o:F::Tvh",
-						main_options, NULL);
+		opt = getopt_long(argc, argv,
+				"au::bdsl::mq:Hk:A::U:P:o:F::TRvh",
+				main_options, NULL);
 		if (opt < 0)
 			break;
 
@@ -2267,7 +2277,10 @@ int main(int argc, char *argv[])
 			extra_opts[num_extra_opts++] = optarg;
 			break;
 		case 'T':
-			time_travel = true;
+			time_travel = 1;
+			break;
+		case 'R':
+			time_travel = 0;
 			break;
 		case 'F':
 			virtiofs_auto = false;
@@ -2324,17 +2337,21 @@ int main(int argc, char *argv[])
 		}
 
 		if (time_travel && !uml_has_time_travel()) {
-			fprintf(stderr, "%s has no time travel support "
+			if (time_travel > 0) {
+				fprintf(stderr, "%s has no time travel support "
 					"(CONFIG_UML_TIME_TRAVEL_SUPPORT)\n",
 					kernel_image);
-			return EXIT_FAILURE;
+				return EXIT_FAILURE;
+			}
+
+			time_travel = 0;
 		}
 
 		printf("Using User Mode Linux kernel %s\n", kernel_image);
 		return start_uml();
 	}
 
-	if (time_travel) {
+	if (time_travel > 0) {
 		fprintf(stderr, "-T needs a User Mode Linux kernel\n");
 		return EXIT_FAILURE;
 	}
-- 
2.56.0


  reply	other threads:[~2026-10-30 21:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 21:29 [PATCH BlueZ v1 00/10] Run test-functional under User Mode Linux Luiz Augusto von Dentz
2026-10-30 21:29 ` Luiz Augusto von Dentz [this message]
2026-10-30 23:58   ` bluez.test.bot
2026-10-30 21:29 ` [PATCH BlueZ v1 02/10] tools/test-runner: Unbind virtio devices before powering off UML Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 03/10] emulator: Answer the time of a guest with a skew Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 04/10] adapter: Don't return Busy when a pending change sets the same value Luiz Augusto von Dentz
2026-10-30 21:34   ` Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 05/10] test: functional: wait for BAP transports to be configured Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 06/10] shared/mcp: Don't drop commands before supported opcodes are read Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 07/10] doc/test-functional: Document User Mode Linux VM hosts Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 08/10] a2dp: Fix refusing the AVDTP connection of a new link Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 09/10] adapter: Don't cancel requests of a new link on stale disconnection Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 10/10] test: Cover A2DP reconnection with a pending disconnection Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261030212940.753771-2-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox