Index: conf/Makefile =================================================================== --- conf/Makefile (nonexistent) +++ conf/Makefile (revision 34376) @@ -0,0 +1,38 @@ +ROOT=../.. +include $(ROOT)/Makefile.conf + +include $(LIBRND_MAK) + +CFLAGS = $(PCB_RND_C89FLAGS) -I$(ROOT)/src -I$(ROOT)/src_3rd $(CFLAGS_LIBRND_FUNGW) $(CFLAGS_LIBRND) +LDLIBS = -lm $(LDFLAGS_LIBRND_FUNGW) $(LDFLAGS_LIBRND) + +LIB_HIDLIB=-lrnd-hid -lrnd-3rd + +HELPER_OBJS= conf_core.o + +DEPH = \ + $(ROOT)/src/librnd/core/conf.h \ + $(ROOT)/src/librnd/core/conf_hid.h \ + $(ROOT)/src/librnd/core/compat_misc.h \ + conf_core.h diag_conf.h + +OBJS = conftest.o help.o + +all: conftest + +conftest: $(OBJS) $(HELPER_OBJS) + $(CC) $(LDFLAGS) $(OBJS) $(HELPER_OBJS) $(LIB_HIDLIB) $(LDLIBS) -o conftest + +conftest.o: conftest.c $(DEPH) + $(CC) $(CFLAGS) -c conftest.c -o conftest.o + +help.o: help.c + +$(LIB_HIDLIB): + cd ../../src && make + +test: + cd tests && $(MAKE) all + +clean: + -$(SCCBOX) rm -f conftest tests/*.out ../../src_plugins/diag/diag_conf.o $(OBJS) Index: conf/conf_core.c =================================================================== --- conf/conf_core.c (nonexistent) +++ conf/conf_core.c (revision 34376) @@ -0,0 +1,19 @@ +#include +#include "conf_core.h" +#include +#include + + +conf_core_t conf_core; + +void pcb_conf_core_postproc(void) { } +void conf_core_uninit_pre(void) { } +void conf_core_uninit(void) { } + +void conf_core_init(void) +{ +#define conf_reg(field,isarray,type_name,cpath,cname,desc,flags) \ + rnd_conf_reg_field(conf_core, field,isarray,type_name,cpath,cname,desc,flags); +#include "conf_core_fields.h" + pcb_conf_core_postproc(); +} Index: conf/conf_core.h =================================================================== --- conf/conf_core.h (nonexistent) +++ conf/conf_core.h (revision 34376) @@ -0,0 +1,21 @@ +#ifndef CONFTEST_CONF_CORE_H +#define CONFTEST_CONF_CORE_H + +#include +#include + +typedef struct { + const struct { + RND_CFT_LIST library_search_paths; + RND_CFT_STRING backup_name; + } rc; + const struct { + struct { + RND_CFT_COLOR layer[64]; + } color; + } appearance; +} conf_core_t; + +extern conf_core_t conf_core; + +#endif Index: conf/conf_core_fields.h =================================================================== --- conf/conf_core_fields.h (nonexistent) +++ conf/conf_core_fields.h (revision 34376) @@ -0,0 +1,3 @@ +conf_reg(rc.library_search_paths, scalar, RND_CFN_LIST, "rc", "library_search_paths", "", 0) +conf_reg(rc.backup_name, scalar, RND_CFN_STRING, "rc", "backup_name", "file name template for periodic backup of board files; optional fields (the usual % substitutions work)", 0) +conf_reg(appearance.color.layer, array, RND_CFN_COLOR, "appearance/color", "layer", "default layer colors; when a new layer is created, a color from this list is assigned initially", 0) Index: conf/conftest.c =================================================================== --- conf/conftest.c (nonexistent) +++ conf/conftest.c (revision 34376) @@ -0,0 +1,390 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "conf_core.h" +#include "diag_conf.h" + +int lineno = 0; +int global_notify = 0; +rnd_conf_hid_id_t hid_id; +const char *hid_cookie = "conftest cookie"; + +const char *pcb_board_get_filename(void) +{ + return "dummy_brd.lht"; +} + +const char *pcb_board_get_name(void) +{ + return "dummy_brd"; +} + + +void watch_pre(rnd_conf_native_t *cfg, int idx) +{ + printf("watch_pre: '%s' old value\n", cfg->hash_path); +} + +void watch_post(rnd_conf_native_t *cfg, int idx) +{ + printf("watch_post: '%s' new value\n", cfg->hash_path); +} + +void notify_pre(rnd_conf_native_t *cfg, int idx) +{ + if (global_notify) + printf("notify_pre: '%s' old value\n", cfg->hash_path); +} + +void notify_post(rnd_conf_native_t *cfg, int idx) +{ + if (global_notify) + printf("notify_post: '%s' new value\n", cfg->hash_path); +} + +rnd_conf_hid_callbacks_t watch_cbs = {watch_pre, watch_post, NULL, NULL}; +rnd_conf_hid_callbacks_t global_cbs = {notify_pre, notify_post, NULL, NULL}; + + +extern lht_doc_t *rnd_conf_main_root[]; +extern void rnd_diag_conf_dump(FILE *f, const char *prefix, int verbose, const char *match_prefix); +void cmd_dump(char *arg) +{ + if (arg == NULL) { + rnd_message(RND_MSG_ERROR, "Need an arg: native or lihata"); + return; + } + if (strncmp(arg, "native", 6) == 0) { + arg+=7; + while(isspace(*arg)) arg++; + rnd_diag_conf_dump(stdout, "", 1, arg); + } + else if (strncmp(arg, "lihata", 6) == 0) { + rnd_conf_role_t role; + arg+=7; + while(isspace(*arg)) arg++; + role = rnd_conf_role_parse(arg); + if (role == RND_CFR_invalid) { + rnd_message(RND_MSG_ERROR, "Invalid role: '%s'", arg); + return; + } + if (rnd_conf_main_root[role] != NULL) + lht_dom_export(rnd_conf_main_root[role]->root, stdout, ""); + else + printf("\n"); + } + else + rnd_message(RND_MSG_ERROR, "Invalid dump mode: '%s'", arg); +} + +void cmd_print(char *arg) +{ + rnd_conf_native_t *node; + gds_t s; + + if (arg == NULL) { + rnd_message(RND_MSG_ERROR, "Need an arg: a native path"); + return; + } + node = rnd_conf_get_field(arg); + if (node == NULL) { + rnd_message(RND_MSG_ERROR, "No such path: '%s'", arg); + return; + } + gds_init(&s); + rnd_conf_print_native((rnd_conf_pfn)rnd_append_printf, &s, NULL, 0, node); + printf("%s='%s'\n", node->hash_path, s.array); + gds_uninit(&s); +} + +void cmd_load(char *arg, int is_text) +{ + char *fn; + rnd_conf_role_t role ; + + if (arg == NULL) { + help:; + rnd_message(RND_MSG_ERROR, "Need 2 args: role and %s", (is_text ? "lihata text" : "file name")); + return; + } + + if (*arg == '*') { + rnd_conf_load_all(NULL, NULL); + return; + } + + fn = strchr(arg, ' '); + if (fn == NULL) + goto help; + *fn = '\0'; + fn++; + while(isspace(*fn)) fn++; + + role = rnd_conf_role_parse(arg); + if (role == RND_CFR_invalid) { + rnd_message(RND_MSG_ERROR, "Invalid role: '%s'", arg); + return; + } + printf("Result: %d\n", rnd_conf_load_as(role, fn, is_text)); + rnd_conf_update(NULL, -1); +} + +rnd_conf_policy_t current_policy = RND_POL_OVERWRITE; +rnd_conf_role_t current_role = RND_CFR_DESIGN; + +void cmd_policy(char *arg) +{ + rnd_conf_policy_t np = rnd_conf_policy_parse(arg); + if (np == RND_POL_invalid) + rnd_message(RND_MSG_ERROR, "Invalid/unknown policy: '%s'", arg); + else + current_policy = np; +} + +void cmd_role(char *arg) +{ + rnd_conf_role_t nr = rnd_conf_role_parse(arg); + if (nr == RND_CFR_invalid) + rnd_message(RND_MSG_ERROR, "Invalid/unknown role: '%s'", arg); + else + current_role = nr; +} + +void cmd_chprio(char *arg) +{ + char *end; + int np = strtol(arg == NULL ? "" : arg, &end, 10); + lht_node_t *first; + + if ((*end != '\0') || (np < 0)) { + rnd_message(RND_MSG_ERROR, "Invalid integer prio: '%s'", arg); + return; + } + first = rnd_conf_lht_get_first(current_role, 0); + if (first != NULL) { + char tmp[128]; + char *end; + end = strchr(first->name, '-'); + if (end != NULL) + *end = '\0'; + sprintf(tmp, "%s-%d", first->name, np); + free(first->name); + first->name = rnd_strdup(tmp); + rnd_conf_update(NULL, -1); + } +} + +void cmd_chpolicy(char *arg) +{ + rnd_conf_policy_t np; + lht_node_t *first; + + if (arg == NULL) { + rnd_message(RND_MSG_ERROR, "need a policy", arg); + return; + } + np = rnd_conf_policy_parse(arg); + if (np == RND_POL_invalid) { + rnd_message(RND_MSG_ERROR, "Invalid integer policy: '%s'", arg); + return; + } + + first = rnd_conf_lht_get_first(current_role, 0); + if (first != NULL) { + char tmp[128]; + char *end; + end = strchr(first->name, '-'); + if (end != NULL) { + sprintf(tmp, "%s%s", arg, end); + free(first->name); + first->name = rnd_strdup(tmp); + } + else { + free(first->name); + first->name = rnd_strdup(arg); + } + rnd_conf_update(NULL, -1); + } +} + +void cmd_set(char *arg) +{ + char *path, *val; + int res; + + path = arg; + val = strpbrk(path, " \t="); + if (val == NULL) { + rnd_message(RND_MSG_ERROR, "set needs a value"); + return; + } + *val = '\0'; + val++; + while(isspace(*val) || (*val == '=')) val++; + + res = rnd_conf_set(current_role, path, -1, val, current_policy); + if (res != 0) + printf("set error: %d\n", res); +} + +void cmd_watch(char *arg, int add) +{ + rnd_conf_native_t *n = rnd_conf_get_field(arg); + if (n == NULL) { + rnd_message(RND_MSG_ERROR, "unknown path"); + return; + } + rnd_conf_hid_set_cb(n, hid_id, (add ? &watch_cbs : NULL)); +} + +void cmd_notify(char *arg) +{ + if (arg != NULL) { + if (strcmp(arg, "on") == 0) + global_notify = 1; + else if (strcmp(arg, "off") == 0) + global_notify = 0; + } + printf("Notify is %s\n", global_notify ? "on" : "off"); +} + +void cmd_echo(char *arg) +{ + if (arg != NULL) + printf("%s\n", arg); +} + +void cmd_reset(char *arg) +{ + if (arg == NULL) { + rnd_conf_reset(current_role, ""); + } + else if (*arg == '*') { + int n; + for(n = 0; n < RND_CFR_max_real; n++) + rnd_conf_reset(n, ""); + } + else { + rnd_conf_role_t role = rnd_conf_role_parse(arg); + if (role == RND_CFR_invalid) { + rnd_message(RND_MSG_ERROR, "Invalid role: '%s'", arg); + return; + } + rnd_conf_reset(role, ""); + } + rnd_conf_update(NULL, -1); +} + +extern void cmd_help(char *arg); + + +char line[8192]; + +/* returns 1 if there's more to read */ +int getline_cont(FILE *f) +{ + char *end = line + strlen(line) - 1; + int offs = 0, cont; + + if (feof(f)) + return 0; + + do { + int remain = sizeof(line)-offs; + assert(remain > 0); + cont = 0; + if (fgets(line+offs, remain, f)) { + char *start = line+offs; + int len = strlen(start); + lineno++; + end = start + len - 1; + while((end >= start) && ((*end == '\n') || (*end == '\r'))) { + *end = '\0'; + end--; + } + if ((end >= start) && (*end == '\\')) { + cont = 1; + *end = '\n'; + } + offs += len-1; + } + else { + if (offs == 0) + return 0; + } + } while(cont); + return 1; +} + +int main() +{ + rnd_app.package = "conftest"; + + hid_id = rnd_conf_hid_reg(hid_cookie, &global_cbs); + + rnd_file_loaded_init(); + rnd_conf_init(); + conf_core_init(); + rnd_hidlib_conf_init(); + rnd_conf_reset(RND_CFR_SYSTEM, "
"); + rnd_conf_reset(RND_CFR_USER, "
"); + + while(getline_cont(stdin)) { + char *arg, *cmd = line; + while(isspace(*cmd)) cmd++; + if ((*cmd == '#') || (*cmd == '\0')) + continue; + arg = strpbrk(cmd, " \t"); + if (arg != NULL) { + *arg = '\0'; + arg++; + while(isspace(*arg)) arg++; + } + + if (strcmp(cmd, "dump") == 0) + cmd_dump(arg); + else if (strcmp(cmd, "print") == 0) + cmd_print(arg); + else if (strcmp(cmd, "load") == 0) + cmd_load(arg, 0); + else if (strcmp(cmd, "paste") == 0) + cmd_load(arg, 1); + else if (strcmp(cmd, "reset") == 0) + cmd_reset(arg); + else if (strcmp(cmd, "set") == 0) + cmd_set(arg); + else if (strcmp(cmd, "policy") == 0) + cmd_policy(arg); + else if (strcmp(cmd, "chprio") == 0) + cmd_chprio(arg); + else if (strcmp(cmd, "chpolicy") == 0) + cmd_chpolicy(arg); + else if (strcmp(cmd, "role") == 0) + cmd_role(arg); + else if (strcmp(cmd, "watch") == 0) + cmd_watch(arg, 1); + else if (strcmp(cmd, "unwatch") == 0) + cmd_watch(arg, 0); + else if (strcmp(cmd, "notify") == 0) + cmd_notify(arg); + else if (strcmp(cmd, "echo") == 0) + cmd_echo(arg); + else if (strcmp(cmd, "help") == 0) + cmd_help(arg); + else + rnd_message(RND_MSG_ERROR, "unknown command '%s'", cmd); + } + + conf_core_uninit_pre(); + rnd_conf_hid_unreg(hid_cookie); + rnd_conf_uninit(); + return 0; +} Index: conf/diag_conf.h =================================================================== --- conf/diag_conf.h (nonexistent) +++ conf/diag_conf.h (revision 34376) @@ -0,0 +1,20 @@ +#ifndef PCB_DIAG_CONF_H +#define PCB_DIAG_CONF_H + +#include + +typedef struct { + const struct { + const struct { + RND_CFT_BOOLEAN auto_integrity; /* Enable (expensive) automatic integrity check after each user action */ + } diag; + } plugins; +} conf_diag_t; + +extern conf_diag_t conf_diag; + +/* Print all configuration items to f, prefixing each line with prefix + If match_prefix is not NULL, print only items with matching path prefix */ +void conf_dump(FILE *f, const char *prefix, int verbose, const char *match_prefix); + +#endif Index: conf/help.c =================================================================== --- conf/help.c (nonexistent) +++ conf/help.c (revision 34376) @@ -0,0 +1,90 @@ +#include +#include +#include + +static const char *help[] = { + "dump", "native", + "Dump all settings as ended up in the native database after the last merge/udpate.", + + "dump", "lihata role", + "Dump all in-memory lihata settings of a given role. For roles, see: help roles", + + "load", "role filename", + "Load a lihata file as role", + + "load", "*", + "Load all roles from disk - the same way as it happens on a normal pcb-rnd startup.", + + "paste", "role lhttxt", + "Paste in-line lihata document lhttxt as role, like if it was loaded from a file", + + "policy", "pol", + "Change current set-policy to pol. This only affects whether a set command inserts, appends or overwrites list-type settings. For valid policies, see: help policies", + + "role", "rol", + "Change current set-policy to rol. This only affects the destination of subsequent set commands. For valid roles, see: help roles", + + "chprio", "prio", + "Change the priority of the first confroot of the current role's in-memory lihata document to prio and merge. Prio is an integer value.", + + "chpolicy", "pol", + "Change the policy of the first confroot of the current role's in-memory lihata document to pol and merge. Pol is a policy, see: help policies", + + "set", "path value", + "Call rnd_conf_set() on a given path with the given value, using the current set-role and the current set-policy. See also: help role; help policy.", + + "watch", "path", + "Announce changes of a given path. See also: help unwatch", + + "unwatch", "path", + "Stop announcing changes of a given path. See also: help watch", + + "notify", "on", + "Turn on global notification on config changes.", + + "notify", "off", + "Turn off global notification on config changes.", + + "echo", "text...", + "Print multi-word text.", + + "reset", "role", + "Reset (make empty) the in-memory lihata document of role; see also: help roles", + + "reset", "*", + "Reset (make empty) all in-memory lihata documents", + +/* misc */ + "roles", NULL, + "Valid roles: system, defaultpcb, user, env, project, design, cli", + + "policies", NULL, + "Valid policies: prepend, append, overwrite", + + NULL, NULL, NULL +}; + +void cmd_help(char *arg) +{ + const char **s; + + printf("\n"); + + if (arg == NULL) { + const char *last = ""; + printf("Try help topic. Available topics:\n"); + for(s = help; s[2] != NULL; s+=3) { + if (strcmp(last, s[0]) != 0) + printf(" %s\n", s[0]); + last = s[0]; + } + return; + } + + for(s = help; s[2] != NULL; s+=3) { + if (strcmp(arg, s[0]) == 0) { + printf("%s %s\n", s[0], (s[1] == NULL ? "" : s[1])); + printf("%s\n\n", s[2]); + } + } +} Index: conf/tests/Makefile =================================================================== --- conf/tests/Makefile (nonexistent) +++ conf/tests/Makefile (revision 34376) @@ -0,0 +1,26 @@ +ROOT=../../.. +include $(ROOT)/Makefile.conf + +TESTS = \ + list_merge.diff \ + list_set.diff \ + arr_merge.diff \ + arr_set.diff \ + scalar.diff + +.SUFFIXES: .ref .test .out .diff .REF + +all: $(TESTS) + @echo "conf: *** QC PASS ***" + +.test.out: + @../conftest < $*.test >$*.out + +.test.REF: + @../conftest < $*.test >$*.ref + @echo $*.ref generated, please validate the content + +.out.diff: + @diff -u $*.ref $*.out + + Index: conf/tests/arr_merge.ref =================================================================== --- conf/tests/arr_merge.ref (nonexistent) +++ conf/tests/arr_merge.ref (revision 34376) @@ -0,0 +1,31 @@ +=== initial state: empty === + I appearance/color/layer[] = +=== import 3 levels === +Result: 0 + I appearance/color/layer[0] = #000001 <> conf_rev=1 + I appearance/color/layer[1] = #000002 <> conf_rev=1 +Result: 0 + I appearance/color/layer[0] = #000101 <> conf_rev=2 + I appearance/color/layer[1] = #000102 <> conf_rev=2 +Result: 0 + I appearance/color/layer[0] = #000201 <> conf_rev=3 + I appearance/color/layer[1] = #000201 <> conf_rev=3 +=== change policy: design->prepend (2, 1) === + I appearance/color/layer[0] = #000201 <> conf_rev=4 + I appearance/color/layer[1] = #000201 <> conf_rev=4 + I appearance/color/layer[2] = #000101 <> conf_rev=4 + I appearance/color/layer[3] = #000102 <> conf_rev=4 +=== change policy: user->append (2, 0, 1) === + I appearance/color/layer[0] = #000201 <> conf_rev=5 + I appearance/color/layer[1] = #000201 <> conf_rev=5 + I appearance/color/layer[2] = #000001 <> conf_rev=5 + I appearance/color/layer[3] = #000002 <> conf_rev=5 + I appearance/color/layer[4] = #000101 <> conf_rev=5 + I appearance/color/layer[5] = #000102 <> conf_rev=5 +=== change policy: design->append (0, 1, 2) === + I appearance/color/layer[0] = #000001 <> conf_rev=6 + I appearance/color/layer[1] = #000002 <> conf_rev=6 + I appearance/color/layer[2] = #000101 <> conf_rev=6 + I appearance/color/layer[3] = #000102 <> conf_rev=6 + I appearance/color/layer[4] = #000201 <> conf_rev=6 + I appearance/color/layer[5] = #000201 <> conf_rev=6 Index: conf/tests/arr_merge.test =================================================================== --- conf/tests/arr_merge.test (nonexistent) +++ conf/tests/arr_merge.test (revision 34376) @@ -0,0 +1,55 @@ +echo === initial state: empty === +reset * +dump native appearance/color/layer + +echo === import 3 levels === +paste system \ + li:pcb-rnd-conf-v1 { \ + ha:overwrite { \ + ha:appearance { \ + ha:color { \ + li:layer = {{#000001}; {#000002};} \ + } \ + } \ + } \ + } +dump native appearance/color/layer + +paste user \ + li:pcb-rnd-conf-v1 { \ + ha:overwrite { \ + ha:appearance { \ + ha:color { \ + li:layer = {{#000101}; {#000102};} \ + } \ + } \ + } \ + } +dump native appearance/color/layer + +paste design \ + li:pcb-rnd-conf-v1 { \ + ha:overwrite { \ + ha:appearance { \ + ha:color { \ + li:layer = {{#000201}; {#000201};} \ + } \ + } \ + } \ + } +dump native appearance/color/layer + +echo === change policy: design->prepend (2, 1) === +role design +chpolicy prepend +dump native appearance/color/layer + +echo === change policy: user->append (2, 0, 1) === +role user +chpolicy append +dump native appearance/color/layer + +echo === change policy: design->append (0, 1, 2) === +role design +chpolicy append +dump native appearance/color/layer Index: conf/tests/arr_set.ref =================================================================== --- conf/tests/arr_set.ref (nonexistent) +++ conf/tests/arr_set.ref (revision 34376) @@ -0,0 +1,37 @@ +=== initial state: empty === + I appearance/color/layer[] = +=== append two items === + I appearance/color/layer[0] = #000001 <:0>> conf_rev=1 + I appearance/color/layer[0] = #000001 <:0>> conf_rev=2 + I appearance/color/layer[1] = #000002 <:0>> conf_rev=2 +=== prepend two items === + I appearance/color/layer[0] = #000003 <:0>> conf_rev=3 + I appearance/color/layer[1] = #000001 <:0>> conf_rev=3 + I appearance/color/layer[2] = #000002 <:0>> conf_rev=3 + I appearance/color/layer[0] = #000004 <:0>> conf_rev=4 + I appearance/color/layer[1] = #000003 <:0>> conf_rev=4 + I appearance/color/layer[2] = #000001 <:0>> conf_rev=4 + I appearance/color/layer[3] = #000002 <:0>> conf_rev=4 +=== overwrite item === + I appearance/color/layer[0] = #000004 <:0>> conf_rev=6 + I appearance/color/layer[1] = #000005 <:0>> conf_rev=6 + I appearance/color/layer[2] = #000001 <:0>> conf_rev=6 + I appearance/color/layer[3] = #000002 <:0>> conf_rev=6 + I appearance/color/layer[0] = #000004 <:0>> conf_rev=7 + I appearance/color/layer[1] = #000005 <:0>> conf_rev=7 + I appearance/color/layer[2] = #000001 <:0>> conf_rev=7 + I appearance/color/layer[3] = #000002 <:0>> conf_rev=7 + I appearance/color/layer[4] = #000006 <:0>> conf_rev=7 + I appearance/color/layer[0] = #000004 <:0>> conf_rev=8 + I appearance/color/layer[1] = #000005 <:0>> conf_rev=8 + I appearance/color/layer[2] = #000001 <:0>> conf_rev=8 + I appearance/color/layer[3] = #000002 <:0>> conf_rev=8 + I appearance/color/layer[4] = #000006 <:0>> conf_rev=8 + I appearance/color/layer[5] = <> conf_rev=8 + I appearance/color/layer[6] = <> conf_rev=8 + I appearance/color/layer[7] = #000007 <:0>> conf_rev=8 +=== overwrite array === + I appearance/color/layer[0] = #000008 <:0>> conf_rev=10 + I appearance/color/layer[1] = #000003 <:0>> conf_rev=10 + I appearance/color/layer[2] = #000001 <:0>> conf_rev=10 + I appearance/color/layer[3] = #000002 <:0>> conf_rev=10 Index: conf/tests/arr_set.test =================================================================== --- conf/tests/arr_set.test (nonexistent) +++ conf/tests/arr_set.test (revision 34376) @@ -0,0 +1,44 @@ +role design + +echo === initial state: empty === +reset * +dump native appearance/color/layer + +echo === append two items === +policy append + +set appearance/color/layer #000001 +dump native appearance/color/layer + +set appearance/color/layer #000002 +dump native appearance/color/layer + +echo === prepend two items === +policy prepend + +set appearance/color/layer #000003 +dump native appearance/color/layer + +set appearance/color/layer #000004 +dump native appearance/color/layer + +echo === overwrite item === +policy overwrite +chprio 710 + +set appearance/color/layer[1] #000005 +dump native appearance/color/layer + +set appearance/color/layer[4] #000006 +dump native appearance/color/layer + +set appearance/color/layer[7] #000007 +dump native appearance/color/layer + + +echo === overwrite array === +policy overwrite +chprio 720 + +set appearance/color/layer #000008 +dump native appearance/color/layer Index: conf/tests/list_merge.ref =================================================================== --- conf/tests/list_merge.ref (nonexistent) +++ conf/tests/list_merge.ref (revision 34376) @@ -0,0 +1,13 @@ +=== initial state: empty === + I rc/library_search_paths = <> conf_rev=0 +=== import 3 levels === +Result: 0 + I rc/library_search_paths = {sys1 <>;sys2 <>;} <> conf_rev=1 +Result: 0 + I rc/library_search_paths = {user1 <>;user2 <>;} <> conf_rev=2 +Result: 0 + I rc/library_search_paths = {design1 <>;design2 <>;} <> conf_rev=3 +=== change policies === + I rc/library_search_paths = {design1 <>;design2 <>;user1 <>;user2 <>;} <> conf_rev=4 + I rc/library_search_paths = {design1 <>;design2 <>;sys1 <>;sys2 <>;user1 <>;user2 <>;} <> conf_rev=5 + I rc/library_search_paths = {sys1 <>;sys2 <>;user1 <>;user2 <>;design1 <>;design2 <>;} <> conf_rev=6 Index: conf/tests/list_merge.test =================================================================== --- conf/tests/list_merge.test (nonexistent) +++ conf/tests/list_merge.test (revision 34376) @@ -0,0 +1,47 @@ +echo === initial state: empty === +reset * +dump native rc/library_search_paths + +echo === import 3 levels === +paste system \ + li:pcb-rnd-conf-v1 { \ + ha:overwrite { \ + ha:rc { \ + li:library_search_paths = { sys1; sys2 } \ + } \ + } \ + } +dump native rc/library_search_paths + +paste user \ + li:pcb-rnd-conf-v1 { \ + ha:overwrite { \ + ha:rc { \ + li:library_search_paths = { user1; user2 } \ + } \ + } \ + } +dump native rc/library_search_paths + +paste design \ + li:pcb-rnd-conf-v1 { \ + ha:overwrite { \ + ha:rc { \ + li:library_search_paths = { design1; design2 } \ + } \ + } \ + } +dump native rc/library_search_paths + +echo === change policies === +role design +chpolicy prepend +dump native rc/library_search_paths + +role user +chpolicy append +dump native rc/library_search_paths + +role design +chpolicy append +dump native rc/library_search_paths Index: conf/tests/list_set.ref =================================================================== --- conf/tests/list_set.ref (nonexistent) +++ conf/tests/list_set.ref (revision 34376) @@ -0,0 +1,10 @@ +=== initial state: empty === + I rc/library_search_paths = <> conf_rev=0 +=== append two items === + I rc/library_search_paths = {foo <:0>>;} <> conf_rev=1 + I rc/library_search_paths = {foo <:0>>;bar <:0>>;} <> conf_rev=2 +=== prepend two items === + I rc/library_search_paths = {pre1 <:0>>;foo <:0>>;bar <:0>>;} <> conf_rev=3 + I rc/library_search_paths = {pre2 <:0>>;pre1 <:0>>;foo <:0>>;bar <:0>>;} <> conf_rev=4 +=== overwrite === + I rc/library_search_paths = {new <:0>>;} <> conf_rev=6 Index: conf/tests/list_set.test =================================================================== --- conf/tests/list_set.test (nonexistent) +++ conf/tests/list_set.test (revision 34376) @@ -0,0 +1,34 @@ +role design + +echo === initial state: empty === +reset * +dump native rc/library_search_paths + +echo === append two items === +policy append + +set rc/library_search_paths foo +dump native rc/library_search_paths + +set rc/library_search_paths bar +dump native rc/library_search_paths + +echo === prepend two items === +policy prepend + +set rc/library_search_paths pre1 +dump native rc/library_search_paths + +set rc/library_search_paths pre2 +dump native rc/library_search_paths + +echo === overwrite === +policy overwrite + +set rc/library_search_paths new + +chprio 710 +# NOTE: have to raise priority because previous prepend and append subtrees also remain in the tree + +dump native rc/library_search_paths + Index: conf/tests/scalar.ref =================================================================== --- conf/tests/scalar.ref (nonexistent) +++ conf/tests/scalar.ref (revision 34376) @@ -0,0 +1,11 @@ +=== initial state === + I rc/backup_name = <> conf_rev=0 +=== setting new values on higher prio should change the final render === + I rc/backup_name = from_user <:0>> conf_rev=0 + I rc/backup_name = from_design <:0>> conf_rev=1 + I rc/backup_name = from_cli <:0>> conf_rev=2 +=== setting new values on lower prio should NOT change the final render === + I rc/backup_name = from_cli <:0>> conf_rev=3 + I rc/backup_name = from_cli <:0>> conf_rev=4 +=== change prio to reorder === + I rc/backup_name = from_design2 <:0>> conf_rev=5 Index: conf/tests/scalar.test =================================================================== --- conf/tests/scalar.test (nonexistent) +++ conf/tests/scalar.test (revision 34376) @@ -0,0 +1,29 @@ +echo === initial state === +dump native rc/backup_name + +echo === setting new values on higher prio should change the final render === +role user +set rc/backup_name from_user +dump native rc/backup_name + +role design +set rc/backup_name from_design +dump native rc/backup_name + +role cli +set rc/backup_name from_cli +dump native rc/backup_name + +echo === setting new values on lower prio should NOT change the final render === +role user +set rc/backup_name from_user2 +dump native rc/backup_name + +role design +set rc/backup_name from_design2 +dump native rc/backup_name + +echo === change prio to reorder === +role cli +chprio 1 +dump native rc/backup_name