summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-05 20:05:27 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-05 21:07:55 -0500
commit2d26d8e07ee680995f96597a1cd713dd81491b89 (patch)
treeca66e286a3319e1edf1d473d7d519c145596ac37 /src/test
parent52e634271fe96ec23a22705ffb87df59a09d1618 (diff)
treewide: replace homegrown memory_erase with explicit_bzero
explicit_bzero was added in glibc 2.25. Make use of it. explicit_bzero is hardcoded to zero the memory, so string erase now truncates the string, instead of overwriting it with 'x'. This causes a visible difference only in the journalctl case.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-string-util.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c
index e43373b0f5..4b3e924cfb 100644
--- a/src/test/test-string-util.c
+++ b/src/test/test-string-util.c
@@ -29,31 +29,20 @@ static void test_string_erase(void) {
assert_se(streq(string_erase(x), ""));
x = strdupa("1");
- assert_se(streq(string_erase(x), "x"));
-
- x = strdupa("12");
- assert_se(streq(string_erase(x), "xx"));
-
- x = strdupa("123");
- assert_se(streq(string_erase(x), "xxx"));
-
- x = strdupa("1234");
- assert_se(streq(string_erase(x), "xxxx"));
-
- x = strdupa("12345");
- assert_se(streq(string_erase(x), "xxxxx"));
-
- x = strdupa("123456");
- assert_se(streq(string_erase(x), "xxxxxx"));
-
- x = strdupa("1234567");
- assert_se(streq(string_erase(x), "xxxxxxx"));
-
- x = strdupa("12345678");
- assert_se(streq(string_erase(x), "xxxxxxxx"));
+ assert_se(streq(string_erase(x), ""));
x = strdupa("123456789");
- assert_se(streq(string_erase(x), "xxxxxxxxx"));
+ assert_se(streq(string_erase(x), ""));
+
+ assert_se(x[1] == '\0');
+ assert_se(x[2] == '\0');
+ assert_se(x[3] == '\0');
+ assert_se(x[4] == '\0');
+ assert_se(x[5] == '\0');
+ assert_se(x[6] == '\0');
+ assert_se(x[7] == '\0');
+ assert_se(x[8] == '\0');
+ assert_se(x[9] == '\0');
}
static void test_ascii_strcasecmp_n(void) {