diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-06-02 13:43:21 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-06-02 13:49:55 +0300 |
commit | 8004bbaa1b31b14dd4c4d3886b5f57b103bf7405 (patch) | |
tree | a6fd826c284fe1e7131c4852c2964b6029ca758d | |
parent | 685600d72b0c300f94c0c69dc0a16c4ebb230a21 (diff) | |
download | pies-8004bbaa1b31b14dd4c4d3886b5f57b103bf7405.tar.gz pies-8004bbaa1b31b14dd4c4d3886b5f57b103bf7405.tar.bz2 |
Speed up tests.
Presence of the ~/.netrc file can slow down execution because of eventual
DNS calls in hostcmp. Provide an option to disable netrc parsing and use
it in tests.
* src/piesctl-cl.opt: New option: --no-netrc.
* doc/pies.texi: Document --no-netrc
* src/piesctl.c (shttp_connect): Don't read ~/.netrc if given --no-netrc.
* tests/env.at: Pass --no-netrc to piesctl.
* tests/respawn.at: Likewise.
* tests/shell.at: Likewise.
* tests/shutdown.at: Likewise.
* tests/startup.at: Likewise.
-rw-r--r-- | doc/pies.texi | 4 | ||||
-rw-r--r-- | src/piesctl-cl.opt | 6 | ||||
-rw-r--r-- | src/piesctl.c | 4 | ||||
-rw-r--r-- | tests/env.at | 4 | ||||
-rw-r--r-- | tests/respawn.at | 2 | ||||
-rw-r--r-- | tests/shell.at | 2 | ||||
-rw-r--r-- | tests/shutdown.at | 4 | ||||
-rw-r--r-- | tests/startup.at | 4 |
8 files changed, 21 insertions, 9 deletions
diff --git a/doc/pies.texi b/doc/pies.texi index 1a798e1..b77a40c 100644 --- a/doc/pies.texi +++ b/doc/pies.texi @@ -3015,24 +3015,28 @@ telinit}, for a detailed discussion. Read configuration from @var{file} instead of the default @file{/etc/piesctl.conf}. @xref{piesctl.conf}, for its description. @item -d @itemx --dump Dump obtained responses verbatim. This is useful mainly for debugging purposes. @item -i @var{inst} @itemx --instance=@var{inst} Talk to @command{pies} instance @var{inst}. +@item --no-netc +@itemx -N +Don't read @file{~/.netrc} file. + @item -u @var{url} @itemx --url=@var{url} Specifies the URL of the communication socket. @xref{piesctl url}, for a description of allowed URL forms. @item -v @itemx --verbose Enable verbose diagnostics. @end table Before parsing, configuration file is preprocessed using @command{m4}. The following options control this feature: diff --git a/src/piesctl-cl.opt b/src/piesctl-cl.opt index f7eaf2a..ebdfec4 100644 --- a/src/piesctl-cl.opt +++ b/src/piesctl-cl.opt @@ -60,24 +60,30 @@ END OPTION(url,u,URL, [<connect to this socket>]) BEGIN if (pies_url_create (&client.url, optarg)) { grecs_error (NULL, 0, _("%s: cannot create URL: %s"), optarg, strerror (errno)); exit (EX_USAGE); } END +OPTION(no-netrc,N,, + [<don't read ~/.netrc file>]) +BEGIN + no_netrc_option = 1; +END + GROUP(Preprocessor) OPTION(include-directory,I,DIR, [<add include directory>]) BEGIN grecs_preproc_add_include_dir (optarg); END OPTION(define,D,[<NAME[=VALUE]>], [<define a preprocessor symbol NAME as having VALUE or empty>]) BEGIN pp_add_option ("-D", optarg); diff --git a/src/piesctl.c b/src/piesctl.c index 0cd2736..4c777d7 100644 --- a/src/piesctl.c +++ b/src/piesctl.c @@ -40,24 +40,25 @@ struct pies_url *default_url; /* Control socket URL */ struct grecs_sockaddr *source_addr; struct client_conn { struct pies_url *url; struct grecs_sockaddr *source_addr; } client; char const *instance = "pies"; char *config_file; char default_config_file[] = SYSCONFDIR "/piesctl.conf"; int preprocess_only; +int no_netrc_option; int verbose; int dump; struct grecs_sockaddr_hints hints = { .flags = GRECS_AH_PASSIVE }; #define EX_OK 0 #define EX_PIES_NOTFOUND 1 int exit_status = EX_OK; static void config_help (void); @@ -534,25 +535,26 @@ shttp_connect (struct pies_url *url, struct grecs_sockaddr *source_addr) if (!fp) { grecs_error (NULL, errno, _("%s: %s failed"), url->string, "fdopen"); close (fd); return NULL; } conn = grecs_zalloc (sizeof (*conn)); conn->fp = fp; if (pies_url_copy (&conn->url, url)) grecs_alloc_die (); - netrc_scan (conn->url); + if (!no_netrc_option) + netrc_scan (conn->url); return conn; } static void shttp_auth_free (struct shttp_connection *conn) { if (conn->b64auth) { memset (conn->b64auth, 0, strlen (conn->b64auth)); free (conn->b64auth); conn->b64auth = NULL; diff --git a/tests/env.at b/tests/env.at index c293c65..18b0e52 100644 --- a/tests/env.at +++ b/tests/env.at @@ -6,30 +6,30 @@ AT_CHECK([ PIES_XFAIL_CHECK PIES_CONTROL_INIT cat > envtest.conf <<_EOT component envtest { env { $3 } command "$abs_builddir/envtest -clone"; chdir $PWD; stdout file "$PWD/log"; return-code 0 { action disable; - exec "piesctl --url unix:///$PWD/pies.ctl shutdown"; + exec "piesctl --url unix:///$PWD/pies.ctl --no-netrc shutdown"; } } _EOT -to 3 \ +to 5 \ envtest -exec \ $abs_top_builddir/src/pies --foreground --stderr \ --config-file control.conf --config-file envtest.conf 2>errlog cat log ], [0], [$4]) AT_CLEANUP]) dnl ############################# dnl Start tests dnl ############################# diff --git a/tests/respawn.at b/tests/respawn.at index 0ba60dc..ab29f11 100644 --- a/tests/respawn.at +++ b/tests/respawn.at @@ -18,25 +18,25 @@ AT_SETUP([Respawn components]) AT_CHECK([ PIES_XFAIL_CHECK PIES_CONTROL_INIT statefile=$PWD/state cat > pies.conf <<_EOT component test { mode respawn; command "$auxdir/respawn $statefile 3"; chdir $PWD; return-code 1 { action disable; - exec "piesctl --url unix:///$PWD/pies.ctl shutdown"; + exec "piesctl --url unix:///$PWD/pies.ctl --no-netrc shutdown"; } } _EOT to 5 \ pies --foreground --stderr \ --config-file control.conf --config-file pies.conf --debug 1 2>errlog cat state ], [0], [3 ]) diff --git a/tests/shell.at b/tests/shell.at index e3d104b..b459d02 100644 --- a/tests/shell.at +++ b/tests/shell.at @@ -20,25 +20,25 @@ AT_CHECK([ PIES_XFAIL_CHECK PIES_CONTROL_INIT statefile=$PWD/state outfile=$PWD/respawn.out cat > pies.conf <<_EOT component test { mode respawn; flags shell; command "if $auxdir/respawn $statefile 3; then echo pass; else exit 1; fi >> $outfile"; chdir $PWD; return-code 1 { action disable; - exec "piesctl --url unix:///$PWD/pies.ctl shutdown"; + exec "piesctl --url unix:///$PWD/pies.ctl --no-netrc shutdown"; } } _EOT set -e to 5 \ pies --foreground --stderr \ --config-file control.conf --config-file pies.conf --debug 1 2>errlog echo state: cat $statefile echo log: diff --git a/tests/shutdown.at b/tests/shutdown.at index 1c2a4ef..24a4504 100644 --- a/tests/shutdown.at +++ b/tests/shutdown.at @@ -20,35 +20,35 @@ AT_CHECK([ PIES_XFAIL_CHECK PIES_CONTROL_INIT statefile=$PWD/state cat > pies.conf <<_EOT component test { mode respawn; command "$auxdir/respawn $statefile 3"; chdir $PWD; return-code 1 { action disable; - exec "piesctl --url unix:///$PWD/pies.ctl shutdown"; + exec "piesctl --url unix:///$PWD/pies.ctl --no-netrc shutdown"; } } component s { mode shutdown; command "$auxdir/touchfile shutdown"; } _EOT set -e to 5 \ pies --foreground --stderr \ - --config-file control.conf --config-file pies.conf 2>errlog + --config-file control.conf --config-file pies.conf --debug 1 2>errlog cat shutdown ], [0], [shutdown ]) AT_CLEANUP diff --git a/tests/startup.at b/tests/startup.at index 22ad25b..b65f9f6 100644 --- a/tests/startup.at +++ b/tests/startup.at @@ -30,33 +30,33 @@ component b2 { mode startup; command "$auxdir/touchfile b2 2"; } component test { mode respawn; command "$auxdir/startcheck b1 b2"; chdir $PWD; stdout file "log.out"; stderr file "log.err"; return-code * { action disable; - exec "piesctl --url unix:///$PWD/pies.ctl shutdown"; + exec "piesctl --url unix:///$PWD/pies.ctl --no-netrc shutdown"; } } _EOT set -e to 5 \ pies --foreground --stderr \ - --config-file control.conf --config-file pies.conf 2>errlog + --config-file control.conf --config-file pies.conf --debug 1 2>errlog cat log.out cat log.err >&2 ], [0], [# b1 b1 # b2 b2 ]) AT_CLEANUP |