Skip to content

Commit

Permalink
fixup! tests/shell: add test for preemption
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Feb 12, 2024
1 parent 29f873a commit fbc94c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
20 changes: 7 additions & 13 deletions tests/sys/shell/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ static int print_empty(int argc, char **argv)
return 0;
}

static char _stack[THREAD_STACKSIZE_SMALL];
static char _stack[THREAD_STACKSIZE_TINY];
static struct {
char msg[64];
unsigned period_ms;
unsigned reps;
uint16_t period_ms;
uint16_t reps;
} _periodic_ctx;

static void *_func(void *arg)
Expand All @@ -114,26 +113,21 @@ static void *_func(void *arg)

while (_periodic_ctx.reps--) {
ztimer_sleep(ZTIMER_MSEC, _periodic_ctx.period_ms);
puts(_periodic_ctx.msg);
puts("test");
}

return NULL;
}

/* test to make sure that waiting for stdin does not block oher threads */

Check failure on line 122 in tests/sys/shell/main.c

View workflow job for this annotation

GitHub Actions / static-tests

There is a typo: oher ==> other, her If this is a false positive, add it to dist/tools/codespell/ignored_words.txt. You can fix this interactively by calling CODESPELL_INTERACTIVE=1 BASE_BRANCH=master ./dist/tools/codespell/check.sh
static int print_periodic(int argc, char **argv)
{
if (argc < 2) {
printf("usage: %s <message> [count]\n", argv[0]);
return -1;
}

if (argc > 2) {
_periodic_ctx.reps = atoi(argv[2]);
if (argc > 1) {
_periodic_ctx.reps = atoi(argv[1]);
} else {
_periodic_ctx.reps = 5;
}

strscpy(_periodic_ctx.msg, argv[1], sizeof(_periodic_ctx.msg));
_periodic_ctx.period_ms = 500;

thread_create(_stack, sizeof(_stack), THREAD_PRIORITY_MAIN, THREAD_CREATE_STACKTEST,
Expand Down
12 changes: 6 additions & 6 deletions tests/sys/shell/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ def check_control_d(child):

def check_preempt(child):
child.expect(PROMPT)
child.sendline('periodic Hello 5')
child.sendline('periodic 5')

child.expect_exact('Hello')
child.expect_exact('Hello')
child.expect_exact('Hello')
child.expect_exact('Hello')
child.expect_exact('Hello')
child.expect_exact('test')
child.expect_exact('test')
child.expect_exact('test')
child.expect_exact('test')
child.expect_exact('test')
child.sendline('')


Expand Down

0 comments on commit fbc94c1

Please sign in to comment.