summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-11-13 14:18:32 +0100
committerTom Gundersen <teg@jklm.no>2015-11-13 14:18:32 +0100
commitcf0f970fe1c6101b45cae8277c221c10398b8e1e (patch)
tree37f8ac193821e520a3c271be7685c06d79300e07 /src/test
parent7152869f0a4a4612022244064cc2b3905b1e3fc7 (diff)
parent765afd5c4dbc71940d6dd6007ecc3eaa5a0b2aa1 (diff)
Merge pull request #1879 from poettering/networkd-forward
stop managing per-interface IP forwarding settings
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-fileio.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index e588681b86..bde3c7c3cf 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -363,6 +363,26 @@ static void test_write_string_file_no_create(void) {
unlink(fn);
}
+static void test_write_string_file_verify(void) {
+ _cleanup_free_ char *buf = NULL, *buf2 = NULL;
+ int r;
+
+ assert_se(read_one_line_file("/proc/cmdline", &buf) >= 0);
+ assert_se((buf2 = strjoin(buf, "\n", NULL)));
+
+ r = write_string_file("/proc/cmdline", buf, 0);
+ assert_se(r == -EACCES || r == -EIO);
+ r = write_string_file("/proc/cmdline", buf2, 0);
+ assert_se(r == -EACCES || r == -EIO);
+
+ assert_se(write_string_file("/proc/cmdline", buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE) == 0);
+ assert_se(write_string_file("/proc/cmdline", buf2, WRITE_STRING_FILE_VERIFY_ON_FAILURE) == 0);
+
+ r = write_string_file("/proc/cmdline", buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_AVOID_NEWLINE);
+ assert_se(r == -EACCES || r == -EIO);
+ assert_se(write_string_file("/proc/cmdline", buf2, WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_AVOID_NEWLINE) == 0);
+}
+
static void test_load_env_file_pairs(void) {
char fn[] = "/tmp/test-load_env_file_pairs-XXXXXX";
int fd;
@@ -419,6 +439,7 @@ int main(int argc, char *argv[]) {
test_write_string_stream();
test_write_string_file();
test_write_string_file_no_create();
+ test_write_string_file_verify();
test_load_env_file_pairs();
return 0;