Skip to content

Commit

Permalink
Merge pull request #1768 from ccoffing/fix-libc-strerror-test
Browse files Browse the repository at this point in the history
Update libc test to match current perror strings
  • Loading branch information
ghaerr authored Dec 8, 2023
2 parents c749f2c + 890dec5 commit e57248f
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions elkscmd/test/libc/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
#include <stdio.h>
#include <string.h>

#define N_ERR_TESTS 5
#define N_ERR_TESTS 4
struct err_tests {
int errno;
const char *msg;
int errno;
const char *msg;
} err_map[N_ERR_TESTS] = {
{ -1, "Unknown error -1" },
{ 0, "Unknown error 0" },
{ 1, "Operation not permitted " },
{ 129, "Server error " },
{ 999, "Unknown error 999" },
{ 0, "Error 0" },
{ 1, "Operation not permitted " },
{ 129, "Server error " },
{ 999, "Error 999" },
};

/* TODO:BUG: /etc/perror is generated with trailing spaces */
TEST_CASE(error_strerror)
{
for (int i = 0; i < N_ERR_TESTS; ++i) {
const char *msg = strerror(err_map[i].errno);
EXPECT_STREQ(msg, err_map[i].msg);
}
for (int i = 0; i < N_ERR_TESTS; ++i) {
const char *msg = strerror(err_map[i].errno);
EXPECT_STREQ(msg, err_map[i].msg);
}
}

0 comments on commit e57248f

Please sign in to comment.