[riot-notifications] [RIOT-OS/RIOT] tests/xtimer_mutex_lock_timeout: add simple case test (#11679)

Gaƫtan Harter notifications at github.com
Wed Jun 12 17:48:45 CEST 2019


cladmi commented on this pull request.

Some minor fixups inside. You can squash them directly.

Please squash everything, I will do a final round of check after.

> + * @brief   List of command for this application.
+ */
+static const shell_command_t shell_commands[] = {
+    { "mutex_timeout_long_unlocked", "unlocked mutex with long timeout",
+      cmd_test_xtimer_mutex_lock_timeout_long_unlocked, },
+    { "mutex_timeout_long_locked", "locked mutex with long timeout",
+      cmd_test_xtimer_mutex_lock_timeout_long_locked, },
+    { NULL, NULL, NULL }
+};
+
+/**
+ * @brief   shell command to test xtimer_mutex_lock_timeout
+ *
+ * the mutex is not locked before the function call and
+ * the timer long. Meaning the timer will get removed
+ * before the triggering.

```suggestion
 * before triggering.
```

> +    if (xtimer_mutex_lock_timeout(&test_mutex, LONG_MUTEX_TIMEOUT) == 0) {
+        puts("OK");
+    }
+    else {
+        puts("error: mutex timed out");
+    }
+
+    return 0;
+}
+
+/**
+ * @brief   shell command to test xtimer_mutex_lock_timeout
+ *
+ * the mutex is locked before the function call and
+ * the timer long. Meaning the timer will get removed
+ * before the triggering.

```suggestion
 * before triggering.
```

> +{
+    (void)argc;
+    (void)argv;
+    puts("starting test: xtimer mutex lock timeout");
+    mutex_t test_mutex = MUTEX_INIT;
+    mutex_lock(&test_mutex);
+
+    if (xtimer_mutex_lock_timeout(&test_mutex, LONG_MUTEX_TIMEOUT) == 0) {
+        puts("Error: mutex taken");
+    }
+    else {
+        puts("OK");
+    }
+
+    return 0;
+

```suggestion
```

No newline here

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11679#pullrequestreview-248854394
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190612/394c8883/attachment.html>


More information about the notifications mailing list