mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-24 02:29:23 +00:00
zdtm/net/ipv6: add test for string stable_secret
stable_secret is always unset in new netns, and we can not restore it to that state after it is set, so just skip save/restore steps Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> Reviewed-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
ac7c8b2493
commit
52bccb262c
1 changed files with 87 additions and 0 deletions
|
|
@ -351,6 +351,81 @@ static int for_each_option_do(int (*f)(FILE *fp, int *conf, int *conf_rand,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define IPV6ADDR_EXAMPLE "2607:f0d0:1002:0051:0000:0000:0000:0004"
|
||||
#define MAX_STR_CONF_LEN 200
|
||||
|
||||
static int set_stable_secret(struct test_conf *tc) {
|
||||
int ret;
|
||||
FILE *fp;
|
||||
char path[PATH_MAX];
|
||||
|
||||
ret = snprintf(path, sizeof(path), "%s/%s", tc->dir6, "stable_secret");
|
||||
if (ret < 0) {
|
||||
pr_perror("snprintf");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = access(path, W_OK);
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
|
||||
fp = fopen(path, "r+");
|
||||
if (fp == NULL) {
|
||||
pr_perror("fopen");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fprintf(fp, IPV6ADDR_EXAMPLE);
|
||||
if (ret < 0) {
|
||||
pr_perror("fprintf");
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_stable_secret(struct test_conf *tc) {
|
||||
int ret;
|
||||
FILE *fp;
|
||||
char path[PATH_MAX];
|
||||
char val[MAX_STR_CONF_LEN+1];
|
||||
|
||||
ret = snprintf(path, sizeof(path), "%s/%s", tc->dir6, "stable_secret");
|
||||
if (ret < 0) {
|
||||
pr_perror("snprintf");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = access(path, W_OK);
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
|
||||
fp = fopen(path, "r+");
|
||||
if (fp == NULL) {
|
||||
pr_perror("fopen");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fscanf(fp, "%s", val);
|
||||
if (ret != 1) {
|
||||
pr_perror("fscanf");
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(val, IPV6ADDR_EXAMPLE)) {
|
||||
fail("Option \"%s\" changed from %s to %s",
|
||||
path, IPV6ADDR_EXAMPLE, val);
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
|
|
@ -366,6 +441,9 @@ int main(int argc, char **argv)
|
|||
if (ret < 0)
|
||||
return -1;
|
||||
ret = for_each_option_do(gen_conf, &lo);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
ret = set_stable_secret(&lo);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
|
|
@ -373,6 +451,9 @@ int main(int argc, char **argv)
|
|||
if (ret < 0)
|
||||
return -1;
|
||||
ret = for_each_option_do(gen_conf, &def);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
ret = set_stable_secret(&def);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
|
|
@ -383,6 +464,9 @@ int main(int argc, char **argv)
|
|||
if (ret < 0)
|
||||
return -1;
|
||||
ret = for_each_option_do(restore_conf, &lo);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
ret = check_stable_secret(&lo);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
|
|
@ -390,6 +474,9 @@ int main(int argc, char **argv)
|
|||
if (ret < 0)
|
||||
return -1;
|
||||
ret = for_each_option_do(restore_conf, &def);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
ret = check_stable_secret(&def);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue