aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2025-04-07 14:27:06 +0000
committerWerner Koch <[email protected]>2025-04-07 14:27:06 +0000
commit9864dd4d66342cca340f8ebe57f46b2fa274bac0 (patch)
treeace2874c1629a27b876e301adfbb80f8611b37c3 /tests
parentAdd a section mode to the name-value functions. (diff)
downloadlibgpg-error-9864dd4d66342cca340f8ebe57f46b2fa274bac0.tar.gz
libgpg-error-9864dd4d66342cca340f8ebe57f46b2fa274bac0.zip
argparse: Make getreg meta command work on Unix.
* src/argparse.c (_gpgrt_argparse_internal_s): Add fields no_registry and registry. (initialize): Init them. (emulated_registry_lookup): New. (handle_meta_getenv): Use it. * tests/etc/t-argparse.conf: Add a getreg meta command. * tests/t-argparse.c (opt): Add a disable-akr command. * tests/etc/Registry: New.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/etc/Registry8
-rw-r--r--tests/etc/t-argparse.conf5
-rw-r--r--tests/t-argparse.c9
4 files changed, 21 insertions, 3 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index abe57b3..4ebb9d7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,7 +19,7 @@
## Process this file with automake to produce Makefile.in
-EXTRA_DIST = t-argparse.conf etc/t-argparse.conf
+EXTRA_DIST = t-argparse.conf etc/t-argparse.conf etc/Registry
gpg_error_lib = ../src/libgpg-error.la
diff --git a/tests/etc/Registry b/tests/etc/Registry
new file mode 100644
index 0000000..fe5598e
--- /dev/null
+++ b/tests/etc/Registry
@@ -0,0 +1,8 @@
+# A test Registry emulation file for t-argparse
+
+[HKCU\Software\GNU\GnuPG]
+DisableAKR: fact
+SomeKey: Value-one
+
+[ \fhghfkhkfh ]
+DisableAKR: yes
diff --git a/tests/etc/t-argparse.conf b/tests/etc/t-argparse.conf
index 92c373d..d8afc9c 100644
--- a/tests/etc/t-argparse.conf
+++ b/tests/etc/t-argparse.conf
@@ -69,6 +69,11 @@ output
# Default key for user john
my-option 42
+[expand]
+[getreg foo HKCU\Software\GNU\GnuPG:DisableAKR]
+disable-akr $foo
+[-expand]
+
# Options applied only for user joy end here.
[user *]
[-info All the following options are applied only if the]
diff --git a/tests/t-argparse.c b/tests/t-argparse.c
index 6085066..666e17d 100644
--- a/tests/t-argparse.c
+++ b/tests/t-argparse.c
@@ -40,6 +40,7 @@ static struct {
int echo;
int a_long_one;
char *street;
+ char *disable_akr;
} opt;
@@ -85,6 +86,7 @@ main (int argc, char **argv)
ARGPARSE_s_n(500, "a-long-option", 0 ),
ARGPARSE_conffile(501, "options", "|FILE|read options from FILE"),
ARGPARSE_noconffile(502, "no-options", "Ignore conf files"),
+ ARGPARSE_s_s(503, "disable-akr", "@" ),
ARGPARSE_verbatim("This epilog consists\nof only 2 lines\n"),
ARGPARSE_end()
};
@@ -93,8 +95,8 @@ main (int argc, char **argv)
| ARGPARSE_FLAG_ONEDASH
| ARGPARSE_FLAG_SYS
| ARGPARSE_FLAG_USER
- /* | ARGPARSE_FLAG_VERBOSE */
- /* | ARGPARSE_FLAG_WITHATTR */
+ | ARGPARSE_FLAG_VERBOSE
+ | ARGPARSE_FLAG_WITHATTR
) };
int i;
const char *srcdir;
@@ -146,6 +148,7 @@ main (int argc, char **argv)
case 'M': opt.myopt = 0; break;
case 's': opt.street = pargs.r.ret_str; break;
case 500: opt.a_long_one++; break;
+ case 503: opt.disable_akr = pargs.r.ret_str; break;
case 601:
case 602:
@@ -176,6 +179,8 @@ main (int argc, char **argv)
printf (" myopt=%d\n", opt.myopt );
if (opt.a_long_one)
printf (" a-long-one=%d\n", opt.a_long_one );
+ if (opt.disable_akr)
+ printf (" disable-akr=%s\n", opt.disable_akr);
if (opt.echo)
printf (" echo=%d\n", opt.echo );