1.1 --- a/tests/dstest_exec.cc Mon Apr 03 22:10:42 2023 +0200
1.2 +++ b/tests/dstest_exec.cc Tue Apr 04 23:11:00 2023 +0200
1.3 @@ -28,6 +28,62 @@
1.4
1.5
1.6
1.7 +static long test_process(int argc, const char *argv[])
1.8 +{
1.9 + /* Obtain the common notifier. */
1.10 +
1.11 + process_notifier_t *notifier = process_notify_task();
1.12 +
1.13 + /* Create a new process structure. */
1.14 +
1.15 + process_t process;
1.16 +
1.17 + process_init(&process);
1.18 +
1.19 + /* Start the process. */
1.20 +
1.21 + long err = process_start(&process, argc, argv);
1.22 +
1.23 + if (err)
1.24 + {
1.25 + printf("Could not start process: %s\n", l4sys_errtostr(err));
1.26 + return err;
1.27 + }
1.28 +
1.29 + printf("Finished program initiation.\n");
1.30 +
1.31 + /* Subscribe to the process for notifications. */
1.32 +
1.33 + err = process_notify_subscribe(&process, NOTIFY_TASK_ALL, notifier);
1.34 +
1.35 + if (err)
1.36 + {
1.37 + printf("Could not subscribe to process: %s\n", l4sys_errtostr(err));
1.38 + return err;
1.39 + }
1.40 +
1.41 + /* Wait for a signal from the process. */
1.42 +
1.43 + err = process_notify_wait_process(&process, notifier);
1.44 +
1.45 + if (err)
1.46 + {
1.47 + printf("Could not wait for process: %s\n", l4sys_errtostr(err));
1.48 + return err;
1.49 + }
1.50 +
1.51 + notify_flags_t flags = process_notifications(&process);
1.52 + notify_values_t values = process_notification_values(&process);
1.53 +
1.54 + printf("End process (flags %" pFMTnotify_flags "x values: %ld, %ld)\n", flags, values.sig, values.val);
1.55 +
1.56 + err = process_error(&process);
1.57 + process_close(&process);
1.58 + return err;
1.59 +}
1.60 +
1.61 +
1.62 +
1.63 int main(int argc, char *argv[])
1.64 {
1.65 long err;
1.66 @@ -42,52 +98,30 @@
1.67
1.68 process_notifier_t *notifier = process_notify_task();
1.69
1.70 - /* Create a new process structure. */
1.71 -
1.72 - process_t process;
1.73 + /* Start a process for a non-existent program. */
1.74
1.75 - process_init(&process);
1.76 + printf("Start non-existent program...\n");
1.77
1.78 - printf("Start process...\n");
1.79 + const char *bad_argv[] = {"non_existent_program"};
1.80
1.81 - /* Start a process for the given program. */
1.82 -
1.83 - err = process_start(&process, argc - 1, argv + 1);
1.84 + err = test_process(1, bad_argv);
1.85
1.86 - if (err)
1.87 + if (!err)
1.88 {
1.89 - printf("Could not start process: %s\n", l4sys_errtostr(err));
1.90 + printf("Non-existent program was apparently successfully started.\n");
1.91 return 1;
1.92 }
1.93
1.94 - printf("Finished program initiation.\n");
1.95 + printf("Non-existent program result: %s\n", l4sys_errtostr(err));
1.96 +
1.97 + /* Start a process for the given program. */
1.98
1.99 - /* Subscribe to the process for notifications. */
1.100 + printf("Start process...\n");
1.101
1.102 - err = process_notify_subscribe(&process, NOTIFY_TASK_SIGNAL, notifier);
1.103 + err = test_process(argc - 1, (const char **) argv + 1);
1.104
1.105 if (err)
1.106 - {
1.107 - printf("Could not subscribe to process: %s\n", l4sys_errtostr(err));
1.108 return 1;
1.109 - }
1.110 -
1.111 - /* Wait for a signal from the process. */
1.112 -
1.113 - err = process_notify_wait_process(&process, notifier);
1.114 -
1.115 - if (err)
1.116 - {
1.117 - printf("Could not wait for process: %s\n", l4sys_errtostr(err));
1.118 - return 1;
1.119 - }
1.120 -
1.121 - notify_flags_t flags = process_notifications(&process);
1.122 - notify_values_t values = process_notification_values(&process);
1.123 -
1.124 - process_close(&process);
1.125 -
1.126 - printf("End process (flags %" pFMTnotify_flags "x values: %ld, %ld)\n", flags, values.sig, values.val);
1.127
1.128 process_notify_close(notifier);
1.129