]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/test/test-fileio.c
codespell: fix spelling errors
[thirdparty/systemd.git] / src / test / test-fileio.c
index 3dd4287ff0f4263080b57b56a34699caa7ab57f9..211def88ebb587e490c79e11e44788fda0b2ed41 100644 (file)
@@ -637,7 +637,7 @@ static void test_fgetc(void) {
         _cleanup_fclose_ FILE *f = NULL;
         char c;
 
-        f = fmemopen((void*) chars, sizeof(chars), "re");
+        f = fmemopen_unlocked((void*) chars, sizeof(chars), "re");
         assert_se(f);
 
         for (unsigned i = 0; i < sizeof(chars); i++) {
@@ -717,7 +717,7 @@ static void test_read_line_one_file(FILE *f) {
         line = mfree(line);
 
         /* read_line() stopped when it hit the limit, that means when we continue reading we'll read at the first
-         * character after the previous limit. Let's make use of tha to continue our test. */
+         * character after the previous limit. Let's make use of that to continue our test. */
         assert_se(read_line(f, 1024, &line) == 62 && streq(line, "line that is supposed to be truncated, because it is so long"));
         line = mfree(line);
 
@@ -727,7 +727,7 @@ static void test_read_line_one_file(FILE *f) {
 static void test_read_line(void) {
         _cleanup_fclose_ FILE *f = NULL;
 
-        f = fmemopen((void*) buffer, sizeof(buffer), "re");
+        f = fmemopen_unlocked((void*) buffer, sizeof(buffer), "re");
         assert_se(f);
 
         test_read_line_one_file(f);
@@ -759,7 +759,11 @@ static void test_read_line3(void) {
         assert_se(f);
 
         r = read_line(f, LINE_MAX, &line);
-        assert_se((size_t) r == strlen(line) + 1);
+        assert_se(r >= 0);
+        if (r == 0)
+                assert_se(line && isempty(line));
+        else
+                assert_se((size_t) r == strlen(line) + 1);
         assert_se(read_line(f, LINE_MAX, NULL) == 0);
 }
 
@@ -788,7 +792,7 @@ static void test_read_line4(void) {
                 _cleanup_fclose_ FILE *f = NULL;
                 _cleanup_free_ char *s = NULL;
 
-                assert_se(f = fmemopen((void*) eof_endings[i].string, eof_endings[i].length, "r"));
+                assert_se(f = fmemopen_unlocked((void*) eof_endings[i].string, eof_endings[i].length, "r"));
 
                 r = read_line(f, (size_t) -1, &s);
                 assert_se((size_t) r == eof_endings[i].length);
@@ -809,7 +813,7 @@ static void test_read_nul_string(void) {
         _cleanup_fclose_ FILE *f = NULL;
         _cleanup_free_ char *s = NULL;
 
-        assert_se(f = fmemopen((void*) test, sizeof(test)-1, "r"));
+        assert_se(f = fmemopen_unlocked((void*) test, sizeof(test)-1, "r"));
 
         assert_se(read_nul_string(f, LONG_LINE_MAX, &s) == 13 && streq_ptr(s, "string nr. 1"));
         s = mfree(s);