diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-09-21 14:10:01 -0700 |
---|---|---|
committer | Tom Hughes <tomhughes@chromium.org> | 2022-09-22 12:49:33 -0700 |
commit | 2bcf863b492fe7ed8105c853814dba6ed32ba719 (patch) | |
tree | fcf6ce5810f9ff9e3c8cce434812dd75492269ed /test/stdlib.c | |
parent | e5fb0b9ba488614b5684e640530f00821ab7b943 (diff) | |
parent | 28712dae9d7ed1e694f7622cc083afa71090d4d5 (diff) | |
download | chrome-ec-2bcf863b492fe7ed8105c853814dba6ed32ba719.tar.gz |
Merge remote-tracking branch cros/main into firmware-fpmcu-bloonchipper-releasefirmware-fpmcu-bloonchipper-release
Generated by: ./util/update_release_branch.py --board bloonchipper
--relevant_paths_file ./util/fingerprint-relevant-paths.txt firmware-
fpmcu-bloonchipper-release
Relevant changes:
git log --oneline e5fb0b9ba4..28712dae9d -- board/hatch_fp
board/bloonchipper common/fpsensor docs/fingerprint driver/fingerprint
util/getversion.sh
ded9307b79 util/getversion.sh: Fix version when not in a git repo
956055e692 board: change Google USB vendor info
71b2ef709d Update license boilerplate text in source code files
33e11afda0 Revert "fpsensor: Build fpsensor source file with C++"
c8d0360723 fpsensor: Build fpsensor source file with C++
bc113abd53 fpsensor: Fix g++ compiler error
150a58a0dc fpsensor: Fix fp_set_sensor_mode return type
b33b5ce85b fpsensor: Remove nested designators for C++ compatibility
2e864b2539 tree-wide: const-ify argv for console commands
56d8b360f9 test: Add test for get ikm failure when seed not set
3a3d6c3690 test: Add test for fpsensor trivial key failure
233e6bbd08 fpsensor_crypto: Abstract calls to hmac_SHA256
0a041b285b docs/fingerprint: Typo correction
c03fab67e2 docs/fingerprint: Fix the path of fputils.py
0b5d4baf5a util/getversion.sh: Fix empty file list handling
6e128fe760 FPMCU dev board environment with Satlab
3eb29b6aa5 builtin: Move ssize_t to sys/types.h
345d62ebd1 docs/fingerprint: Update power numbers for latest dartmonkey release
c25ffdb316 common: Conditionally support printf %l and %i modifiers
9a3c514b45 test: Add a test to check if the debugger is connected
54e603413f Move standard library tests to their own file
43fa6b4bf8 docs/fingerprint: Update power numbers for latest bloonchipper release
25536f9a84 driver/fingerprint/fpc/bep/fpc_sensor_spi.c: Format with clang-format
4face99efd driver/fingerprint/fpc/libfp/fpc_sensor_pal.h: Format with clang-format
738de2b575 trng: Rename rand to trng_rand
14b8270edd docs/fingerprint: Update dragonclaw power numbers
0b268f93d1 driver/fingerprint/fpc/libfp/fpc_private.c: Format with clang-format
f80da163f2 driver/fingerprint/fpc/libfp/fpc_private.h: Format with clang-format
5e9c85c9b1 driver/fingerprint/fpc/libfp/fpc_sensor_pal.c: Format with clang-format
c1f9dd3cf8 driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h: Format with clang-format
eb1e1bed8d driver/fingerprint/fpc/libfp/fpc1145_private.h: Format with clang-format
6e7b611821 driver/fingerprint/fpc/bep/fpc_bio_algorithm.h: Format with clang-format
e0589cd5e2 driver/fingerprint/fpc/bep/fpc1035_private.h: Format with clang-format
7905e556a0 common/fpsensor/fpsensor_crypto.c: Format with clang-format
21289d170c driver/fingerprint/fpc/bep/fpc1025_private.h: Format with clang-format
98a20f937e common/fpsensor/fpsensor_state.c: Format with clang-format
a2d255d8af common/fpsensor/fpsensor.c: Format with clang-format
73055eeb3f driver/fingerprint/fpc/bep/fpc_private.c: Format with clang-format
0f7b5cb509 common/fpsensor/fpsensor_private.h: Format with clang-format
1ceade6e65 driver/fingerprint/fpc/bep/fpc_private.h: Format with clang-format
dc3e9008b8 board/hatch_fp/board.h: Format with clang-format
dca9d74321 Revert "trng: Rename rand to trng_rand"
a6b0b3554f trng: Rename rand to trng_rand
28d0b75b70 third_party/boringssl: Remove unused header
BRANCH=None
BUG=b:246424843 b:234181908 b:244781166 b:234181908 b:244387210
BUG=b:242720240 chromium:1098010 b:180945056 b:236025198 b:234181908
BUG=b:234181908 b:237344361 b:131913998 b:236386294 b:234143158
BUG=b:234781655 b:215613183 b:242720910
TEST=`make -j buildall`
TEST=./test/run_device_tests.py --board bloonchipper
Test "aes": PASSED
Test "cec": PASSED
Test "cortexm_fpu": PASSED
Test "crc": PASSED
Test "flash_physical": PASSED
Test "flash_write_protect": PASSED
Test "fpsensor_hw": PASSED
Test "fpsensor_spi_ro": PASSED
Test "fpsensor_spi_rw": PASSED
Test "fpsensor_uart_ro": PASSED
Test "fpsensor_uart_rw": PASSED
Test "mpu_ro": PASSED
Test "mpu_rw": PASSED
Test "mutex": PASSED
Test "pingpong": PASSED
Test "printf": PASSED
Test "queue": PASSED
Test "rollback_region0": PASSED
Test "rollback_region1": PASSED
Test "rollback_entropy": PASSED
Test "rtc": PASSED
Test "sha256": PASSED
Test "sha256_unrolled": PASSED
Test "static_if": PASSED
Test "stdlib": PASSED
Test "system_is_locked_wp_on": PASSED
Test "system_is_locked_wp_off": PASSED
Test "timer_dos": PASSED
Test "utils": PASSED
Test "utils_str": PASSED
Test "stm32f_rtc": PASSED
Test "panic_data_bloonchipper_v2.0.4277": PASSED
Test "panic_data_bloonchipper_v2.0.5938": PASSED
Force-Relevant-Builds: all
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I264ad0ffe7afcd507a1e483c6e934a9c4fea47c3
Diffstat (limited to 'test/stdlib.c')
-rw-r--r-- | test/stdlib.c | 520 |
1 files changed, 520 insertions, 0 deletions
diff --git a/test/stdlib.c b/test/stdlib.c new file mode 100644 index 0000000000..efff64829d --- /dev/null +++ b/test/stdlib.c @@ -0,0 +1,520 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Test standard library functions. + */ + +#include "common.h" +#include "console.h" +#include "system.h" +#include "printf.h" +#include "shared_mem.h" +#include "test_util.h" +#include "timer.h" +#include "util.h" + +#ifdef USE_BUILTIN_STDLIB +static const bool use_builtin_stdlib = true; +#else +static const bool use_builtin_stdlib = false; +#endif + +static int test_isalpha(void) +{ + TEST_ASSERT(isalpha('a')); + TEST_ASSERT(isalpha('z')); + TEST_ASSERT(isalpha('A')); + TEST_ASSERT(isalpha('Z')); + TEST_ASSERT(!isalpha('0')); + TEST_ASSERT(!isalpha('~')); + TEST_ASSERT(!isalpha(' ')); + TEST_ASSERT(!isalpha('\0')); + TEST_ASSERT(!isalpha('\n')); + return EC_SUCCESS; +} + +static int test_isprint(void) +{ + TEST_ASSERT(isprint('a')); + TEST_ASSERT(isprint('z')); + TEST_ASSERT(isprint('A')); + TEST_ASSERT(isprint('Z')); + TEST_ASSERT(isprint('0')); + TEST_ASSERT(isprint('~')); + TEST_ASSERT(isprint(' ')); + TEST_ASSERT(!isprint('\0')); + TEST_ASSERT(!isprint('\n')); + return EC_SUCCESS; +} + +static int test_strstr(void) +{ + const char s1[] = "abcde"; + + TEST_ASSERT(strstr(s1, "ab") == s1); + if (use_builtin_stdlib) { + /* + * TODO(http://b/243192369): This is incorrect and should be + * fixed. + */ + TEST_ASSERT(strstr(s1, "") == NULL); + } else { + /* + * From the man page: If needle is the empty string, the return + * value is always haystack itself. + */ + TEST_ASSERT(strstr(s1, "") == s1); + } + TEST_ASSERT(strstr("", "ab") == NULL); + TEST_ASSERT(strstr("", "x") == NULL); + TEST_ASSERT(strstr(s1, "de") == &s1[3]); + TEST_ASSERT(strstr(s1, "def") == NULL); + + return EC_SUCCESS; +} + +static int test_strtoull(void) +{ + char *e; + + TEST_ASSERT(strtoull("10", &e, 0) == 10); + TEST_ASSERT(e && (*e == '\0')); + TEST_ASSERT(strtoull("010", &e, 0) == 8); + TEST_ASSERT(e && (*e == '\0')); + TEST_ASSERT(strtoull("+010", &e, 0) == 8); + TEST_ASSERT(e && (*e == '\0')); + + if (use_builtin_stdlib) { + /* + * TODO(http://b/243192369): This is incorrect and should be + * fixed. + */ + TEST_ASSERT(strtoull("-010", &e, 0) == 0); + TEST_ASSERT(e && (*e == '-')); + } else { + /* + * From the man page: The strtoull() function returns either + * the result of the conversion or, if there was a leading + * minus sign, the negation of the result of the conversion + * represented as an unsigned value, unless the original + * (nonnegated) value would overflow + */ + TEST_ASSERT(strtoull("-010", &e, 0) == 0xFFFFFFFFFFFFFFF8); + } + + TEST_ASSERT(strtoull("0x1f z", &e, 0) == 31); + TEST_ASSERT(e && (*e == ' ')); + TEST_ASSERT(strtoull("0X1f z", &e, 0) == 31); + TEST_ASSERT(e && (*e == ' ')); + TEST_ASSERT(strtoull("10a", &e, 16) == 266); + TEST_ASSERT(e && (*e == '\0')); + TEST_ASSERT(strtoull("0x02C", &e, 16) == 44); + TEST_ASSERT(e && (*e == '\0')); + TEST_ASSERT(strtoull("+0x02C", &e, 16) == 44); + TEST_ASSERT(e && (*e == '\0')); + + if (use_builtin_stdlib) { + /* + * TODO(http://b/243192369): This is incorrect and should be + * fixed. + */ + TEST_ASSERT(strtoull("-0x02C", &e, 16) == 0); + TEST_ASSERT(e && (*e == '-')); + } else { + TEST_ASSERT(strtoull("-0x02C", &e, 16) == 0xFFFFFFFFFFFFFFD4); + } + + TEST_ASSERT(strtoull("0x02C", &e, 0) == 44); + TEST_ASSERT(e && (*e == '\0')); + TEST_ASSERT(strtoull("+0x02C", &e, 0) == 44); + TEST_ASSERT(e && (*e == '\0')); + + if (use_builtin_stdlib) { + /* + * TODO(http://b/243192369): This is incorrect and should be + * fixed. + */ + TEST_ASSERT(strtoull("-0x02C", &e, 0) == 0); + TEST_ASSERT(e && (*e == '-')); + } else { + TEST_ASSERT(strtoull("-0x02C", &e, 0) == 0xFFFFFFFFFFFFFFD4); + } + + TEST_ASSERT(strtoull("0X02C", &e, 16) == 44); + TEST_ASSERT(e && (*e == '\0')); + TEST_ASSERT(strtoull("+0X02C", &e, 16) == 44); + TEST_ASSERT(e && (*e == '\0')); + + if (use_builtin_stdlib) { + /* + * TODO(http://b/243192369): This is incorrect and should be + * fixed. + */ + TEST_ASSERT(strtoull("-0X02C", &e, 16) == 0); + TEST_ASSERT(e && (*e == '-')); + } else { + TEST_ASSERT(strtoull("-0X02C", &e, 16) == 0xFFFFFFFFFFFFFFD4); + } + + TEST_ASSERT(strtoull("0X02C", &e, 0) == 44); + TEST_ASSERT(e && (*e == '\0')); + TEST_ASSERT(strtoull("+0X02C", &e, 0) == 44); + TEST_ASSERT(e && (*e == '\0')); + + if (use_builtin_stdlib) { + /* + * TODO(http://b/243192369): This is incorrect and should be + * fixed. + */ + TEST_ASSERT(strtoull("-0X02C", &e, 0) == 0); + TEST_ASSERT(e && (*e == '-')); + } else { + TEST_ASSERT(strtoull("-0X02C", &e, 0) == 0xFFFFFFFFFFFFFFD4); + } + + if (use_builtin_stdlib) { + /* + * TODO(http://b/243192369): This is incorrect and should be + * fixed. + */ + TEST_ASSERT(strtoull(" -12", &e, 0) == 0); + TEST_ASSERT(e && (*e == '-')); + } else { + TEST_ASSERT(strtoull(" -12", &e, 0) == 0xFFFFFFFFFFFFFFF4); + } + + TEST_ASSERT(strtoull("!", &e, 0) == 0); + TEST_ASSERT(e && (*e == '!')); + + TEST_ASSERT(strtoull("+!", &e, 0) == 0); + if (use_builtin_stdlib) { + /* + * TODO(http://b/243192369): This is incorrect and should be + * fixed. + */ + TEST_ASSERT(e && (*e == '!')); + } else { + TEST_ASSERT(e && (*e == '+')); + } + + TEST_ASSERT(strtoull("+0!", &e, 0) == 0); + TEST_ASSERT(e && (*e == '!')); + + TEST_ASSERT(strtoull("+0x!", &e, 0) == 0); + if (use_builtin_stdlib) { + TEST_ASSERT(e && (*e == '!')); + } else { + if (IS_ENABLED(EMU_BUILD)) + TEST_ASSERT(e && (*e == 'x')); + else + TEST_ASSERT(e && (*e == '+')); + } + + TEST_ASSERT(strtoull("+0X!", &e, 0) == 0); + if (use_builtin_stdlib) { + TEST_ASSERT(e && (*e == '!')); + } else { + if (IS_ENABLED(EMU_BUILD)) + TEST_ASSERT(e && (*e == 'X')); + else + TEST_ASSERT(e && (*e == '+')); + } + + return EC_SUCCESS; +} + +static int test_strncpy(void) +{ + char dest[10]; + + strncpy(dest, "test", 10); + TEST_ASSERT_ARRAY_EQ("test", dest, 5); + strncpy(dest, "12345", 6); + TEST_ASSERT_ARRAY_EQ("12345", dest, 6); + /* + * gcc complains: + * error: ‘__builtin_strncpy’ output truncated copying 10 bytes from a + * string of length 12 [-Werror=stringop-truncation] + */ +#pragma GCC diagnostic push +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif + strncpy(dest, "testtesttest", 10); +#pragma GCC diagnostic pop + TEST_ASSERT_ARRAY_EQ("testtestte", dest, 10); + + return EC_SUCCESS; +} + +static int test_strncmp(void) +{ + TEST_ASSERT(strncmp("123", "123", 8) == 0); + TEST_ASSERT(strncmp("789", "456", 8) > 0); + TEST_ASSERT(strncmp("abc", "abd", 4) < 0); + TEST_ASSERT(strncmp("abc", "abd", 2) == 0); + return EC_SUCCESS; +} + +static int test_strlen(void) +{ + TEST_ASSERT(strlen("this is a string") == 16); + return EC_SUCCESS; +} + +static int test_strnlen(void) +{ + TEST_ASSERT(strnlen("this is a string", 17) == 16); + TEST_ASSERT(strnlen("this is a string", 16) == 16); + TEST_ASSERT(strnlen("this is a string", 5) == 5); + + return EC_SUCCESS; +} + +static int test_strcasecmp(void) +{ + TEST_ASSERT(strcasecmp("test string", "TEST strIng") == 0); + TEST_ASSERT(strcasecmp("test123!@#", "TesT123!@#") == 0); + TEST_ASSERT(strcasecmp("lower", "UPPER") != 0); + return EC_SUCCESS; +} + +static int test_strncasecmp(void) +{ + TEST_ASSERT(strncasecmp("test string", "TEST str", 4) == 0); + TEST_ASSERT(strncasecmp("test string", "TEST str", 8) == 0); + TEST_ASSERT(strncasecmp("test123!@#", "TesT321!@#", 5) != 0); + TEST_ASSERT(strncasecmp("test123!@#", "TesT321!@#", 4) == 0); + TEST_ASSERT(strncasecmp("1test123!@#", "1TesT321!@#", 5) == 0); + TEST_ASSERT(strncasecmp("1test123", "teststr", 0) == 0); + return EC_SUCCESS; +} + +static int test_atoi(void) +{ + TEST_ASSERT(atoi(" 901") == 901); + TEST_ASSERT(atoi("-12c") == -12); + TEST_ASSERT(atoi(" 0 ") == 0); + TEST_ASSERT(atoi("\t111") == 111); + return EC_SUCCESS; +} + +static int test_snprintf(void) +{ + char buffer[32]; + + TEST_ASSERT(snprintf(buffer, sizeof(buffer), "%u", 1234) == 4); + TEST_ASSERT(strncmp(buffer, "1234", sizeof(buffer)) == 0); + return EC_SUCCESS; +} + +static int test_strcspn(void) +{ + const char str1[] = "abc"; + const char str2[] = "This is a string\nwith newlines!"; + + TEST_EQ(strcspn(str1, "a"), (size_t)0, "%zu"); + TEST_EQ(strcspn(str1, "b"), (size_t)1, "%zu"); + TEST_EQ(strcspn(str1, "c"), (size_t)2, "%zu"); + TEST_EQ(strcspn(str1, "ccc"), (size_t)2, "%zu"); + TEST_EQ(strcspn(str1, "cba"), (size_t)0, "%zu"); + TEST_EQ(strcspn(str1, "cb"), (size_t)1, "%zu"); + TEST_EQ(strcspn(str1, "bc"), (size_t)1, "%zu"); + TEST_EQ(strcspn(str1, "cbc"), (size_t)1, "%zu"); + TEST_EQ(strcspn(str1, "z"), strlen(str1), "%zu"); + TEST_EQ(strcspn(str1, "xyz"), strlen(str1), "%zu"); + TEST_EQ(strcspn(str1, ""), strlen(str1), "%zu"); + + TEST_EQ(strcspn(str2, " "), (size_t)4, "%zu"); + TEST_EQ(strcspn(str2, "\n"), (size_t)16, "%zu"); + TEST_EQ(strcspn(str2, "\n "), (size_t)4, "%zu"); + TEST_EQ(strcspn(str2, "!"), strlen(str2) - 1, "%zu"); + TEST_EQ(strcspn(str2, "z"), strlen(str2), "%zu"); + TEST_EQ(strcspn(str2, "z!"), strlen(str2) - 1, "%zu"); + + return EC_SUCCESS; +} + +static int test_memmove(void) +{ + int i; + timestamp_t t0, t1, t2, t3; + char *buf; + const int buf_size = 1000; + const int len = 400; + const int iteration = 1000; + + TEST_ASSERT(shared_mem_acquire(buf_size, &buf) == EC_SUCCESS); + + for (i = 0; i < len; ++i) + buf[i] = i & 0x7f; + for (i = len; i < buf_size; ++i) + buf[i] = 0; + + t0 = get_time(); + for (i = 0; i < iteration; ++i) + memmove(buf + 101, buf, len); /* unaligned */ + t1 = get_time(); + TEST_ASSERT_ARRAY_EQ(buf + 101, buf, len); + ccprintf(" (speed gain: %" PRId64 " ->", t1.val - t0.val); + + t2 = get_time(); + for (i = 0; i < iteration; ++i) + memmove(buf + 100, buf, len); /* aligned */ + t3 = get_time(); + ccprintf(" %" PRId64 " us) ", t3.val - t2.val); + TEST_ASSERT_ARRAY_EQ(buf + 100, buf, len); + + if (!IS_ENABLED(EMU_BUILD) && use_builtin_stdlib) + TEST_ASSERT((t1.val - t0.val) > (t3.val - t2.val)); + + /* Test small moves */ + memmove(buf + 1, buf, 1); + TEST_ASSERT_ARRAY_EQ(buf + 1, buf, 1); + memmove(buf + 5, buf, 4); + memmove(buf + 1, buf, 4); + TEST_ASSERT_ARRAY_EQ(buf + 1, buf + 5, 4); + + shared_mem_release(buf); + return EC_SUCCESS; +} + +static int test_memcpy(void) +{ + int i; + timestamp_t t0, t1, t2, t3; + char *buf; + const int buf_size = 1000; + const int len = 400; + const int dest_offset = 500; + const int iteration = 1000; + + TEST_ASSERT(shared_mem_acquire(buf_size, &buf) == EC_SUCCESS); + + for (i = 0; i < len; ++i) + buf[i] = i & 0x7f; + for (i = len; i < buf_size; ++i) + buf[i] = 0; + + t0 = get_time(); + for (i = 0; i < iteration; ++i) + memcpy(buf + dest_offset + 1, buf, len); /* unaligned */ + t1 = get_time(); + TEST_ASSERT_ARRAY_EQ(buf + dest_offset + 1, buf, len); + ccprintf(" (speed gain: %" PRId64 " ->", t1.val - t0.val); + + t2 = get_time(); + for (i = 0; i < iteration; ++i) + memcpy(buf + dest_offset, buf, len); /* aligned */ + t3 = get_time(); + ccprintf(" %" PRId64 " us) ", t3.val - t2.val); + TEST_ASSERT_ARRAY_EQ(buf + dest_offset, buf, len); + + if (!IS_ENABLED(EMU_BUILD)) + TEST_ASSERT((t1.val - t0.val) > (t3.val - t2.val)); + + memcpy(buf + dest_offset + 1, buf + 1, len - 1); + TEST_ASSERT_ARRAY_EQ(buf + dest_offset + 1, buf + 1, len - 1); + + /* Test small copies */ + memcpy(buf + dest_offset, buf, 1); + TEST_ASSERT_ARRAY_EQ(buf + dest_offset, buf, 1); + memcpy(buf + dest_offset, buf, 4); + TEST_ASSERT_ARRAY_EQ(buf + dest_offset, buf, 4); + memcpy(buf + dest_offset + 1, buf, 1); + TEST_ASSERT_ARRAY_EQ(buf + dest_offset + 1, buf, 1); + memcpy(buf + dest_offset + 1, buf, 4); + TEST_ASSERT_ARRAY_EQ(buf + dest_offset + 1, buf, 4); + + shared_mem_release(buf); + return EC_SUCCESS; +} + +/* Plain memset, used as a reference to measure speed gain */ +static void *dumb_memset(void *dest, int c, int len) +{ + char *d = (char *)dest; + while (len > 0) { + *(d++) = c; + len--; + } + return dest; +} + +static int test_memset(void) +{ + int i; + timestamp_t t0, t1, t2, t3; + char *buf; + const int buf_size = 1000; + const int len = 400; + const int iteration = 1000; + + TEST_ASSERT(shared_mem_acquire(buf_size, &buf) == EC_SUCCESS); + + t0 = get_time(); + for (i = 0; i < iteration; ++i) + dumb_memset(buf, 1, len); + t1 = get_time(); + TEST_ASSERT_MEMSET(buf, (char)1, len); + ccprintf(" (speed gain: %" PRId64 " ->", t1.val - t0.val); + + t2 = get_time(); + for (i = 0; i < iteration; ++i) + memset(buf, 1, len); + t3 = get_time(); + TEST_ASSERT_MEMSET(buf, (char)1, len); + ccprintf(" %" PRId64 " us) ", t3.val - t2.val); + + if (!IS_ENABLED(EMU_BUILD)) + TEST_ASSERT((t1.val - t0.val) > (t3.val - t2.val)); + + memset(buf, 128, len); + TEST_ASSERT_MEMSET(buf, (char)128, len); + + memset(buf, -2, len); + TEST_ASSERT_MEMSET(buf, (char)-2, len); + + memset(buf + 1, 1, len - 2); + TEST_ASSERT_MEMSET(buf + 1, (char)1, len - 2); + + shared_mem_release(buf); + return EC_SUCCESS; +} + +static int test_memchr(void) +{ + char *buf = "1234"; + + TEST_ASSERT(memchr("123567890", '4', 8) == NULL); + TEST_ASSERT(memchr("123", '3', 2) == NULL); + TEST_ASSERT(memchr(buf, '3', 4) == buf + 2); + TEST_ASSERT(memchr(buf, '4', 4) == buf + 3); + return EC_SUCCESS; +} + +void run_test(int argc, const char **argv) +{ + test_reset(); + + RUN_TEST(test_isalpha); + RUN_TEST(test_isprint); + RUN_TEST(test_strstr); + RUN_TEST(test_strtoull); + RUN_TEST(test_strncpy); + RUN_TEST(test_strncmp); + RUN_TEST(test_strlen); + RUN_TEST(test_strnlen); + RUN_TEST(test_strcasecmp); + RUN_TEST(test_strncasecmp); + RUN_TEST(test_atoi); + RUN_TEST(test_snprintf); + RUN_TEST(test_strcspn); + RUN_TEST(test_memmove); + RUN_TEST(test_memcpy); + RUN_TEST(test_memset); + RUN_TEST(test_memchr); + + test_print_result(); +} |