t = lxc_deslashify(s);
if (!t)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort(strcmp(t, "/A/B/C/D/E") == 0);
free(t);
t = lxc_deslashify(s);
if (!t)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort(strcmp(t, "/A") == 0);
free(t);
t = lxc_deslashify(s);
if (!t)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort(strcmp(t, "") == 0);
free(t);
t = lxc_deslashify(s);
if (!t)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort(strcmp(t, "/") == 0);
free(t);
}
for (i = 0; i < sizeof(mountinfo) / sizeof(mountinfo[0]); i++) {
if (strcmp(mountinfo[i], "24 0 8:2 / / rw - rootfs rootfs rw,size=1004396k,nr_inodes=251099") == 0)
continue;
+
if (fprintf(fp2, "%s\n", mountinfo[i]) < 0) {
lxc_error("Could not write \"%s\" to temporary file.", mountinfo[i]);
goto non_test_error;
fclose(fp1);
else if (fd1 > 0)
close(fd1);
+
if (fp2)
fclose(fp2);
else if (fd2 > 0)
}
close(init_ns);
}
+
if (fret == EXIT_SUCCESS)
return;
+
exit(fret);
}
ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRIu64, (uint64_t)UINT_MAX);
if (ret < 0 || ret >= LXC_NUMSTRLEN64)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort((0 == lxc_safe_uint(numstr, &n)) && n == UINT_MAX);
ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRIu64, (uint64_t)UINT_MAX + 1);
if (ret < 0 || ret >= LXC_NUMSTRLEN64)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort((-ERANGE == lxc_safe_uint(numstr, &n)));
lxc_test_assert_abort((0 == lxc_safe_uint("1234345", &n)) && n == 1234345);
ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRIu64, (uint64_t)INT_MAX);
if (ret < 0 || ret >= LXC_NUMSTRLEN64)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort((0 == lxc_safe_int(numstr, &n)) && n == INT_MAX);
ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRIu64, (uint64_t)INT_MAX + 1);
if (ret < 0 || ret >= LXC_NUMSTRLEN64)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort((-ERANGE == lxc_safe_int(numstr, &n)));
ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRId64, (int64_t)INT_MIN);
if (ret < 0 || ret >= LXC_NUMSTRLEN64)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort((0 == lxc_safe_int(numstr, &n)) && n == INT_MIN);
ret = snprintf(numstr, LXC_NUMSTRLEN64, "%" PRId64, (int64_t)INT_MIN - 1);
if (ret < 0 || ret >= LXC_NUMSTRLEN64)
exit(EXIT_FAILURE);
+
lxc_test_assert_abort((-ERANGE == lxc_safe_int(numstr, &n)));
lxc_test_assert_abort((0 == lxc_safe_int("1234345", &n)) && n == 1234345);
lxc_error("%s\n", "Failed to parse \"0\"");
exit(EXIT_FAILURE);
}
+
if (n != 0) {
lxc_error("%s\n", "Failed to parse \"0\"");
exit(EXIT_FAILURE);
lxc_error("%s\n", "Failed to parse \"1\"");
exit(EXIT_FAILURE);
}
+
if (n != 1) {
lxc_error("%s\n", "Failed to parse \"1\"");
exit(EXIT_FAILURE);
lxc_error("%s\n", "Failed to parse \"1B\"");
exit(EXIT_FAILURE);
}
+
if (n != 1) {
lxc_error("%s\n", "Failed to parse \"1B\"");
exit(EXIT_FAILURE);
lxc_error("%s\n", "Failed to parse \"1kB\"");
exit(EXIT_FAILURE);
}
+
if (n != 1024) {
lxc_error("%s\n", "Failed to parse \"1kB\"");
exit(EXIT_FAILURE);
lxc_error("%s\n", "Failed to parse \"1MB\"");
exit(EXIT_FAILURE);
}
+
if (n != 1048576) {
lxc_error("%s\n", "Failed to parse \"1MB\"");
exit(EXIT_FAILURE);
lxc_error("%s\n", "Failed to parse \"1 B\"");
exit(EXIT_FAILURE);
}
+
if (n != 1) {
lxc_error("%s\n", "Failed to parse \"1 B\"");
exit(EXIT_FAILURE);
lxc_error("%s\n", "Failed to parse \"1 kB\"");
exit(EXIT_FAILURE);
}
+
if (n != 1024) {
lxc_error("%s\n", "Failed to parse \"1 kB\"");
exit(EXIT_FAILURE);
lxc_error("%s\n", "Failed to parse \"1 MB\"");
exit(EXIT_FAILURE);
}
+
if (n != 1048576) {
lxc_error("%s\n", "Failed to parse \"1 MB\"");
exit(EXIT_FAILURE);
if (lxc_config_net_hwaddr("lxc.net"))
exit(EXIT_FAILURE);
+
if (lxc_config_net_hwaddr("lxc.net."))
exit(EXIT_FAILURE);
+
if (lxc_config_net_hwaddr("lxc.net.0."))
exit(EXIT_FAILURE);
}