1 /* Copyright (c) 2001-2004, Roger Dingledine.
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2021, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
8 #define STATEFILE_PRIVATE
10 #include "core/or/or.h"
11 #include "lib/encoding/confline.h"
12 #include "app/config/statefile.h"
14 #include "test/test.h"
17 test_statefile_remove_obsolete(void *arg
)
20 config_line_t
*inp
= NULL
;
21 /* try empty config */
22 or_state_remove_obsolete_lines(&inp
);
25 /* try removing every line */
26 config_line_append(&inp
, "EntryGuard", "doesn't matter");
27 config_line_append(&inp
, "HidServRevCounter", "ignore");
28 config_line_append(&inp
, "hidservrevcounter", "foobar"); // note case
29 or_state_remove_obsolete_lines(&inp
);
32 /* Now try removing a subset of lines. */
33 config_line_append(&inp
, "EntryGuard", "doesn't matter");
34 config_line_append(&inp
, "Guard", "in use");
35 config_line_append(&inp
, "HidServRevCounter", "ignore");
36 config_line_append(&inp
, "TorVersion", "this test doesn't care");
37 or_state_remove_obsolete_lines(&inp
);
39 tt_str_op(inp
->key
, OP_EQ
, "Guard");
40 tt_str_op(inp
->value
, OP_EQ
, "in use");
42 tt_str_op(inp
->next
->key
, OP_EQ
, "TorVersion");
43 tt_str_op(inp
->next
->value
, OP_EQ
, "this test doesn't care");
44 tt_assert(! inp
->next
->next
);
47 config_free_lines(inp
);
51 { #name, test_statefile_##name, 0, NULL, NULL }
53 struct testcase_t statefile_tests
[] = {