Add a symlink to the verilator UART pseudo device for testing
Allow unique device file name to be used in bazel test
Change-Id: I04adc6ac4cd7d520207d4adc3fce2f1149ed1cbc
diff --git a/hw/dv/dpi/uartdpi/uartdpi.c b/hw/dv/dpi/uartdpi/uartdpi.c
index 479162f..e08f1e2 100644
--- a/hw/dv/dpi/uartdpi/uartdpi.c
+++ b/hw/dv/dpi/uartdpi/uartdpi.c
@@ -47,6 +47,16 @@
"$ screen %s\n",
ctx->ptyname, name, ctx->ptyname);
+ const char *test_out_dir = getenv("TEST_UNDECLARED_OUTPUTS_DIR");
+ const int kMaxPathLen = 512;
+ if (test_out_dir) {
+ char device_file[kMaxPathLen] = {0};
+ snprintf(device_file, kMaxPathLen, "%s/%s_device", test_out_dir, name);
+ if (symlink(ctx->ptyname, device_file) == 0) {
+ printf("Created symlink device %s for %s.\n", device_file, name);
+ }
+ }
+
// Open log file (if requested)
ctx->log_file = NULL;
bool write_log_file = strlen(log_file_path) != 0;
@@ -57,8 +67,6 @@
} else {
FILE *log_file;
- const char *test_out_dir = getenv("TEST_UNDECLARED_OUTPUTS_DIR");
- const int kMaxPathLen = 512;
char test_out_log_file[kMaxPathLen] = {0};
if (test_out_dir) {
snprintf(test_out_log_file, kMaxPathLen, "%s/%s", test_out_dir,