summaryrefslogtreecommitdiff
path: root/src/test/test-strv.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-09-17 10:03:46 -0500
committerLennart Poettering <lennart@poettering.net>2013-09-17 10:06:50 -0500
commit19f6d710772305610b928bc2678b9d77fe11e770 (patch)
treeca3e7b4f7f20f94137fcef96b92a7a208c72e1c5 /src/test/test-strv.c
parent0aafd43d235982510d1c40564079f7bcec0c7c19 (diff)
specifier: rework specifier calls to return proper error message
Previously the specifier calls could only indicate OOM by returning NULL. With this change they will return negative errno-style error codes like everything else.
Diffstat (limited to 'src/test/test-strv.c')
-rw-r--r--src/test/test-strv.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 25bee22dfe..6513d2e07b 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -28,18 +28,30 @@
static void test_specifier_printf(void) {
_cleanup_free_ char *w = NULL;
+ int r;
const Specifier table[] = {
{ 'a', specifier_string, (char*) "AAAA" },
{ 'b', specifier_string, (char*) "BBBB" },
+ { 'm', specifier_machine_id, NULL },
+ { 'B', specifier_boot_id, NULL },
+ { 'H', specifier_host_name, NULL },
+ { 'v', specifier_kernel_release, NULL },
{ 0, NULL, NULL }
};
- w = specifier_printf("xxx a=%a b=%b yyy", table, NULL);
+ r = specifier_printf("xxx a=%a b=%b yyy", table, NULL, &w);
+ assert_se(r >= 0);
+ assert_se(w);
+
puts(w);
+ assert_se(streq(w, "xxx a=AAAA b=BBBB yyy"));
+ free(w);
+ r = specifier_printf("machine=%m, boot=%B, host=%H, version=%v", table, NULL, &w);
+ assert_se(r >= 0);
assert_se(w);
- assert_se(streq(w, "xxx a=AAAA b=BBBB yyy"));
+ puts(w);
}
static const char* const input_table_multiple[] = {