diff options
author | Simon Tatham <anakin@pobox.com> | 2017-05-28 09:54:05 +0100 |
---|---|---|
committer | Simon Tatham <anakin@pobox.com> | 2017-05-28 09:54:05 +0100 |
commit | fe5eb01f9b84b344bd1d476f409626fd7b4cd5f9 (patch) | |
tree | d378e92065fa90a1cce69eb38b3b3351ea6b3d50 | |
parent | f501b2927d7e4bf6b26c1e348270e6f4a48ffb27 (diff) | |
download | wix-on-linux-fe5eb01f9b84b344bd1d476f409626fd7b4cd5f9.tar.gz wix-on-linux-fe5eb01f9b84b344bd1d476f409626fd7b4cd5f9.tar.bz2 wix-on-linux-fe5eb01f9b84b344bd1d476f409626fd7b4cd5f9.zip |
Add a command-line test program.
At the moment it only tests MsiGetFileVersion, because that's the
piece I just found a problem in, but I could easily extend it to have
convenient command-line test rigs for other parts of this setup too.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 7 | ||||
-rw-r--r-- | api.h | 6 | ||||
-rw-r--r-- | misc.h | 1 | ||||
-rw-r--r-- | test.c | 33 | ||||
-rw-r--r-- | uchars.c | 2 | ||||
-rw-r--r-- | uchars.h | 2 | ||||
-rw-r--r-- | version.c | 1 |
8 files changed, 50 insertions, 3 deletions
@@ -7,6 +7,7 @@ | |||
7 | *.a | 7 | *.a |
8 | *.so | 8 | *.so |
9 | *.so.* | 9 | *.so.* |
10 | /test | ||
10 | /Makefile | 11 | /Makefile |
11 | /Makefile.in | 12 | /Makefile.in |
12 | /aclocal.m4 | 13 | /aclocal.m4 |
diff --git a/Makefile.am b/Makefile.am index f2695f1..e952730 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -2,6 +2,8 @@ libdir = $(bindir) | |||
2 | 2 | ||
3 | ACLOCAL_AMFLAGS = -I m4 | 3 | ACLOCAL_AMFLAGS = -I m4 |
4 | 4 | ||
5 | noinst_PROGRAMS = test | ||
6 | |||
5 | lib_LTLIBRARIES = libwinterop.la libmsi.la libpreload.la | 7 | lib_LTLIBRARIES = libwinterop.la libmsi.la libpreload.la |
6 | 8 | ||
7 | libwinterop_la_SOURCES = makecab.c readcab.c winterop-stubs.c \ | 9 | libwinterop_la_SOURCES = makecab.c readcab.c winterop-stubs.c \ |
@@ -9,11 +11,14 @@ memory.c memory.h dupstr.c dupstr.h subproc.c subproc.h uchars.c \ | |||
9 | uchars.h | 11 | uchars.h |
10 | 12 | ||
11 | libmsi_la_SOURCES = makemsi.c md5.c memory.c memory.h version.c \ | 13 | libmsi_la_SOURCES = makemsi.c md5.c memory.c memory.h version.c \ |
12 | dupstr.c dupstr.h subproc.c subproc.h uchars.c uchars.h | 14 | dupstr.c dupstr.h subproc.c subproc.h uchars.c uchars.h api.h |
13 | 15 | ||
14 | libpreload_la_SOURCES = preload.c | 16 | libpreload_la_SOURCES = preload.c |
15 | libpreload_la_LDFLAGS = -ldl | 17 | libpreload_la_LDFLAGS = -ldl |
16 | 18 | ||
19 | test_SOURCES = test.c api.h misc.h | ||
20 | test_LDADD = libmsi.la | ||
21 | |||
17 | bin_SCRIPTS = wrapper.py makecab.py | 22 | bin_SCRIPTS = wrapper.py makecab.py |
18 | 23 | ||
19 | install-exec-hook: | 24 | install-exec-hook: |
@@ -0,0 +1,6 @@ | |||
1 | #include <stdint.h> | ||
2 | #include <uchar.h> | ||
3 | |||
4 | uint32_t MsiGetFileVersionW(const char16_t *filename, | ||
5 | char16_t *version, uint32_t *version_size, | ||
6 | char16_t *language, uint32_t *language_size); | ||
@@ -0,0 +1 @@ | |||
#define lenof(x) (sizeof(x)/sizeof(*(x))) | |||
@@ -0,0 +1,33 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <string.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <stdint.h> | ||
5 | #include <inttypes.h> | ||
6 | |||
7 | #include "misc.h" | ||
8 | #include "uchars.h" | ||
9 | #include "api.h" | ||
10 | |||
11 | int main(int argc, char **argv) | ||
12 | { | ||
13 | if (argc > 2 && !strcmp(argv[1], "version")) { | ||
14 | const char *filename8 = argv[2]; | ||
15 | char16_t filename16[4096]; | ||
16 | uint32_t filename16size = lenof(filename16); | ||
17 | c16cpy(filename16, &filename16size, filename8); | ||
18 | char16_t version[4096], language[4096]; | ||
19 | uint32_t versionsize = lenof(version), languagesize = lenof(language); | ||
20 | uint32_t retd = | ||
21 | MsiGetFileVersionW(filename16, version, &versionsize, | ||
22 | language, &languagesize); | ||
23 | printf("MsiGetFileVersionW(\"%s\") = %"PRId32"\n", filename8, retd); | ||
24 | if (retd == 0) { | ||
25 | printf(" version = \"%s\"\n language = \"%s\"\n", | ||
26 | ascii(version, false), ascii(language, false)); | ||
27 | } | ||
28 | } else { | ||
29 | fprintf(stderr, "usage: ./test version <file>\n"); | ||
30 | return 1; | ||
31 | } | ||
32 | return 0; | ||
33 | } | ||
@@ -16,7 +16,7 @@ char *ascii(const char16_t *wstr, bool translate_slashes) | |||
16 | return ret; | 16 | return ret; |
17 | } | 17 | } |
18 | 18 | ||
19 | void c16cpy(char16_t *out, uint32_t *outsize, char *s) | 19 | void c16cpy(char16_t *out, uint32_t *outsize, const char *s) |
20 | { | 20 | { |
21 | uint32_t retlen = 0; | 21 | uint32_t retlen = 0; |
22 | while (retlen < *outsize) { | 22 | while (retlen < *outsize) { |
@@ -3,4 +3,4 @@ | |||
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | 4 | ||
5 | char *ascii(const char16_t *wstr, bool translate_slashes); | 5 | char *ascii(const char16_t *wstr, bool translate_slashes); |
6 | void c16cpy(char16_t *out, uint32_t *outsize, char *s); | 6 | void c16cpy(char16_t *out, uint32_t *outsize, const char *s); |
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include "memory.h" | 12 | #include "memory.h" |
13 | #include "uchars.h" | 13 | #include "uchars.h" |
14 | #include "api.h" | ||
14 | 15 | ||
15 | uint32_t MsiGetFileVersionW(const char16_t *filename, | 16 | uint32_t MsiGetFileVersionW(const char16_t *filename, |
16 | char16_t *version, uint32_t *version_size, | 17 | char16_t *version, uint32_t *version_size, |