From 3a5d156690f01145cba2175683823c5d0f134058 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 24 Oct 2022 13:54:02 +0200 Subject: [PATCH] Docs: C struct style Tests: changed waiting->wait backend --- doc/DEVELOP.md | 27 ++++++++++++++++++++++--- test/test_api.sh | 2 +- test/test_augment_state.sh | 3 ++- test/test_augment_trans.sh | 3 ++- test/test_client.sh | 2 +- test/test_identity.sh | 2 +- test/test_leafref_uses_augment.sh | 2 +- test/test_nacm.sh | 2 +- test/test_nacm_credentials.sh | 2 +- test/test_nacm_datanode.sh | 2 +- test/test_nacm_datanode_paths.sh | 2 +- test/test_nacm_datanode_read.sh | 2 +- test/test_nacm_datanode_write.sh | 2 +- test/test_nacm_ext.sh | 2 +- test/test_nacm_module_read.sh | 2 +- test/test_nacm_protocol.sh | 2 +- test/test_netconf_filter.sh | 2 +- test/test_netconf_notifications.sh | 2 +- test/test_netconf_whitespace.sh | 2 +- test/test_perf_cli.sh | 2 +- test/test_perf_mem.sh | 2 +- test/test_perf_netconf.sh | 2 +- test/test_perf_restconf.sh | 2 +- test/test_perf_restconf_ssl.sh | 2 +- test/test_privileges.sh | 2 +- test/test_restconf_notifications.sh | 2 +- test/test_rpc.sh | 2 +- test/test_startup.sh | 2 +- test/test_upgrade_auto.sh | 2 +- test/test_upgrade_interfaces.sh | 2 +- test/test_upgrade_interfaces_rfc7895.sh | 2 +- test/test_upgrade_repair.sh | 2 +- test/test_upgrade_simple.sh | 6 +++--- 33 files changed, 60 insertions(+), 37 deletions(-) diff --git a/doc/DEVELOP.md b/doc/DEVELOP.md index 9d2c2d25..b358d1bb 100644 --- a/doc/DEVELOP.md +++ b/doc/DEVELOP.md @@ -47,15 +47,14 @@ myfn(int par1, ms = NULL; ``` Notes: -1. the return type of the function and all qualifers on first line (`static int`) -2. function name and first parameter on second line, thereafter each parameter on own line +1. The return type of the function and all qualifers on first line (`static int`) +2. Function name and first parameter on second line, thereafter each parameter on own line 3. Each parameter indented to match the "longest" (`my_structure`) 4. Pointer declarations written: `type *p`, not: `type* p`. 5. All local variables in a function declared at top of function, not inline with C-statements. 6. Local variables can be initialized with scalars or constants, not eg malloc or functions with return values that need to be checked for errors 7. There is a single empty line between local variable declarations and the first function statement. - Function signatures are declared in include files or in forward declaration using "one-line" syntax, unless very long: ``` static int myfn(int par1, my_structure *par2); @@ -123,6 +122,28 @@ files, there is only a single level of include file dependencies. The drawback is that the same include file may need to be repeated in many .c files. +### Structs + +Struct fields should have a prefix to distinguish them from other struct fields. The prefix should use an abbreviation of the struct name. + +Example: +``` +struct my_struct{ + int ms_foo; + char *ms_string[42]; +} +``` +where `ms_` is the prefix and is an abbreviation of `my_struct`. + +### Global variables + +Try to avoid global variables. + +If you absolutely need one, try to contain it as static within a +single C-file, ie do not declare it extern and use it elsewhere. + +Also, always prepend a global variable with `_`, underscore. + ## How to work in git Clixon uses semantic versioning (https://semver.org). diff --git a/test/test_api.sh b/test/test_api.sh index 69a03b26..1ea6847d 100755 --- a/test/test_api.sh +++ b/test/test_api.sh @@ -228,7 +228,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_augment_state.sh b/test/test_augment_state.sh index 582b71a6..70824e71 100755 --- a/test/test_augment_state.sh +++ b/test/test_augment_state.sh @@ -144,7 +144,8 @@ if [ $BE -ne 0 ]; then new "start backend -s init -f $cfg -- -sS $fstate" start_backend -s init -f $cfg -- -sS $fstate fi -new "waiting" + +new "wait backend" wait_backend #----------------------------- diff --git a/test/test_augment_trans.sh b/test/test_augment_trans.sh index a0aa53d2..df99b6cd 100755 --- a/test/test_augment_trans.sh +++ b/test/test_augment_trans.sh @@ -109,7 +109,8 @@ if [ $BE -ne 0 ]; then new "start backend -s init -f $cfg" start_backend -s init -f $cfg fi -new "waiting" + +new "wait backend" wait_backend new "get-config empty" diff --git a/test/test_client.sh b/test/test_client.sh index eb7efb32..77ab340d 100755 --- a/test/test_client.sh +++ b/test/test_client.sh @@ -138,7 +138,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_identity.sh b/test/test_identity.sh index 7e07e2ab..795680e4 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -197,7 +197,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_leafref_uses_augment.sh b/test/test_leafref_uses_augment.sh index bc11b24f..4ed1ad94 100755 --- a/test/test_leafref_uses_augment.sh +++ b/test/test_leafref_uses_augment.sh @@ -114,7 +114,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend new "cli set t1-con t1-con t1-a 123" diff --git a/test/test_nacm.sh b/test/test_nacm.sh index 963a5cd0..701bfb26 100755 --- a/test/test_nacm.sh +++ b/test/test_nacm.sh @@ -123,7 +123,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_nacm_credentials.sh b/test/test_nacm_credentials.sh index 937adc69..948c4929 100755 --- a/test/test_nacm_credentials.sh +++ b/test/test_nacm_credentials.sh @@ -135,7 +135,7 @@ EOF start_backend -s init -f $cfg fi - new "waiting" + new "wait backend" wait_backend # First push in nacm rules via regular means diff --git a/test/test_nacm_datanode.sh b/test/test_nacm_datanode.sh index 4ff4d6e8..44c62ca6 100755 --- a/test/test_nacm_datanode.sh +++ b/test/test_nacm_datanode.sh @@ -226,7 +226,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_nacm_datanode_paths.sh b/test/test_nacm_datanode_paths.sh index f64f0595..39f80785 100755 --- a/test/test_nacm_datanode_paths.sh +++ b/test/test_nacm_datanode_paths.sh @@ -100,7 +100,7 @@ if [ $BE -ne 0 ]; then start_backend -s startup -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_nacm_datanode_read.sh b/test/test_nacm_datanode_read.sh index 002e672c..791a0a33 100755 --- a/test/test_nacm_datanode_read.sh +++ b/test/test_nacm_datanode_read.sh @@ -231,7 +231,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_nacm_datanode_write.sh b/test/test_nacm_datanode_write.sh index be66222b..a34943a7 100755 --- a/test/test_nacm_datanode_write.sh +++ b/test/test_nacm_datanode_write.sh @@ -227,7 +227,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh index 470b8a2f..678ada8d 100755 --- a/test/test_nacm_ext.sh +++ b/test/test_nacm_ext.sh @@ -191,7 +191,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -s fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index 334f4a8f..18ae136a 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -184,7 +184,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -s fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index f37d911f..60bd3fe3 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -145,7 +145,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_netconf_filter.sh b/test/test_netconf_filter.sh index 05346d1b..8929442e 100755 --- a/test/test_netconf_filter.sh +++ b/test/test_netconf_filter.sh @@ -56,7 +56,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend new "Add two entries" diff --git a/test/test_netconf_notifications.sh b/test/test_netconf_notifications.sh index 84c4c61c..116efa66 100755 --- a/test/test_netconf_notifications.sh +++ b/test/test_netconf_notifications.sh @@ -101,7 +101,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -n # create example notification stream fi -new "waiting" +new "wait backend" wait_backend # diff --git a/test/test_netconf_whitespace.sh b/test/test_netconf_whitespace.sh index 76793223..59ee5549 100755 --- a/test/test_netconf_whitespace.sh +++ b/test/test_netconf_whitespace.sh @@ -73,7 +73,7 @@ if [ $BE -ne 0 ]; then start_backend -s startup -f $cfg fi -new "waiting" +new "wait backend" wait_backend new "get startup" diff --git a/test/test_perf_cli.sh b/test/test_perf_cli.sh index a0fd852a..88cdd6d8 100755 --- a/test/test_perf_cli.sh +++ b/test/test_perf_cli.sh @@ -83,7 +83,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -s fi -new "waiting" +new "wait backend" wait_backend new "generate config with $perfnr list entries" diff --git a/test/test_perf_mem.sh b/test/test_perf_mem.sh index e6dd1ec2..567ce45e 100755 --- a/test/test_perf_mem.sh +++ b/test/test_perf_mem.sh @@ -85,7 +85,7 @@ function testrun(){ start_backend -s startup -f $cfg fi - new "waiting" + new "wait backend" wait_backend pid=$(cat $pidfile) diff --git a/test/test_perf_netconf.sh b/test/test_perf_netconf.sh index 7beb12b9..e4b8f669 100755 --- a/test/test_perf_netconf.sh +++ b/test/test_perf_netconf.sh @@ -87,7 +87,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -s fi -new "waiting" +new "wait backend" wait_backend # Check this later with committed data diff --git a/test/test_perf_restconf.sh b/test/test_perf_restconf.sh index a1140eb0..b97716c1 100755 --- a/test/test_perf_restconf.sh +++ b/test/test_perf_restconf.sh @@ -106,7 +106,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -s fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_perf_restconf_ssl.sh b/test/test_perf_restconf_ssl.sh index 0e230fd9..3670cc66 100755 --- a/test/test_perf_restconf_ssl.sh +++ b/test/test_perf_restconf_ssl.sh @@ -122,7 +122,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -s fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_privileges.sh b/test/test_privileges.sh index 17c5af0e..7c9702b5 100755 --- a/test/test_privileges.sh +++ b/test/test_privileges.sh @@ -96,7 +96,7 @@ function testrun(){ err 1 $c fi - new "waiting" + new "wait backend" wait_backend if [ $expecterr -eq 1 ]; then diff --git a/test/test_restconf_notifications.sh b/test/test_restconf_notifications.sh index b7e671ec..35d2c177 100755 --- a/test/test_restconf_notifications.sh +++ b/test/test_restconf_notifications.sh @@ -149,7 +149,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -n # create example notification stream fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_rpc.sh b/test/test_rpc.sh index ab7dd0a4..d77d2c48 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -196,7 +196,7 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg fi -new "waiting" +new "wait backend" wait_backend if [ $RC -ne 0 ]; then diff --git a/test/test_startup.sh b/test/test_startup.sh index a90e5198..cf89990b 100755 --- a/test/test_startup.sh +++ b/test/test_startup.sh @@ -124,7 +124,7 @@ function testrun(){ new "start backend -f $cfg -s $mode -c $dir/extra_db" start_backend -s $mode -f $cfg -c $dir/extra_db - new "waiting" + new "wait backend" wait_backend else new "Restart backend as eg follows: -Ff $cfg -s $mode -c $dir/extra_db # $BETIMEOUT s" diff --git a/test/test_upgrade_auto.sh b/test/test_upgrade_auto.sh index 69543002..7c522ba2 100755 --- a/test/test_upgrade_auto.sh +++ b/test/test_upgrade_auto.sh @@ -258,7 +258,7 @@ if [ $BE -ne 0 ]; then start_backend -s $mode -f $cfg fi -new "waiting" +new "wait backend" wait_backend new "Check running db content" diff --git a/test/test_upgrade_interfaces.sh b/test/test_upgrade_interfaces.sh index 58aa5d4c..26edf74d 100755 --- a/test/test_upgrade_interfaces.sh +++ b/test/test_upgrade_interfaces.sh @@ -271,7 +271,7 @@ function testrun(){ start_backend -s startup -f $cfg -- -u fi - new "waiting" + new "wait backend" wait_backend new "Check running db content" diff --git a/test/test_upgrade_interfaces_rfc7895.sh b/test/test_upgrade_interfaces_rfc7895.sh index 49b72302..cb4c9643 100755 --- a/test/test_upgrade_interfaces_rfc7895.sh +++ b/test/test_upgrade_interfaces_rfc7895.sh @@ -268,7 +268,7 @@ function testrun(){ start_backend -s startup -f $cfg -- -u fi - new "waiting" + new "wait backend" wait_backend new "Check running db content" diff --git a/test/test_upgrade_repair.sh b/test/test_upgrade_repair.sh index e83297ad..233d8f42 100755 --- a/test/test_upgrade_repair.sh +++ b/test/test_upgrade_repair.sh @@ -117,7 +117,7 @@ if [ $BE -ne 0 ]; then start_backend -s $mode -f $cfg fi -new "waiting" +new "wait backend" wait_backend new "Check running db content is failsafe" diff --git a/test/test_upgrade_simple.sh b/test/test_upgrade_simple.sh index d8682b0f..605c744e 100755 --- a/test/test_upgrade_simple.sh +++ b/test/test_upgrade_simple.sh @@ -111,11 +111,11 @@ EOF if [ $BE -ne 0 ]; then new "start backend -s running -f $cfg" start_backend -s running -f $cfg - - new "waiting" - wait_backend fi +new "wait backend" +wait_backend + new "netconf get config" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" ""