Skip to content

Commit 857cd36

Browse files
committed
Addressed another round of reviews (copilot)
1 parent a64fa8f commit 857cd36

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

hal/library.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void hal_prepare_boot(void)
8383
return;
8484
}
8585

86-
static void wolfBoot_panic(void)
86+
static void library_panic(void)
8787
{
8888
wolfBoot_printf("wolfBoot: PANIC!\n");
8989
exit('P');

tools/unit-tests/unit-delta.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,27 +493,49 @@ START_TEST(test_wb_diff_get_sector_size_rejects_values_above_16bit)
493493
char *saved_copy = saved ? strdup(saved) : NULL;
494494
pid_t pid;
495495
int status = 0;
496+
int setenv_ok;
497+
int fork_ok = 0;
498+
int wait_ok = 0;
499+
int exited_ok = 0;
500+
int exit_code = -1;
501+
502+
setenv_ok = (setenv("WOLFBOOT_SECTOR_SIZE", "0x20000", 1) == 0);
503+
if (!setenv_ok) {
504+
goto restore_env;
505+
}
496506

497-
ck_assert_int_eq(setenv("WOLFBOOT_SECTOR_SIZE", "0x20000", 1), 0);
498507
pid = fork();
499-
ck_assert_int_ne(pid, -1);
508+
if (pid != -1) {
509+
fork_ok = 1;
510+
}
500511

501512
if (pid == 0) {
502513
(void)wb_diff_get_sector_size();
503514
_exit(0);
504515
}
505516

506-
ck_assert_int_eq(waitpid(pid, &status, 0), pid);
507-
ck_assert(WIFEXITED(status));
508-
ck_assert_int_eq(WEXITSTATUS(status), 6);
517+
if (fork_ok && (waitpid(pid, &status, 0) == pid)) {
518+
wait_ok = 1;
519+
exited_ok = WIFEXITED(status);
520+
if (exited_ok) {
521+
exit_code = WEXITSTATUS(status);
522+
}
523+
}
509524

525+
restore_env:
510526
if (saved_copy != NULL) {
511527
ck_assert_int_eq(setenv("WOLFBOOT_SECTOR_SIZE", saved_copy, 1), 0);
512528
free(saved_copy);
513529
}
514530
else {
515531
ck_assert_int_eq(unsetenv("WOLFBOOT_SECTOR_SIZE"), 0);
516532
}
533+
534+
ck_assert(setenv_ok);
535+
ck_assert(fork_ok);
536+
ck_assert(wait_ok);
537+
ck_assert(exited_ok);
538+
ck_assert_int_eq(exit_code, 6);
517539
#else
518540
ck_assert_int_eq(1, 1);
519541
#endif

0 commit comments

Comments
 (0)