Re: [PATCH 4/9] configurator: Use native directory separator

David Gibson <[email protected]> Tue, 20 Sep 2016 15:04:29 +1000
Newsgroups org.ozlabs.lists.ccan
Message-ID <20160920050429.GN20488@umbus>
On Sun, Sep 18, 2016 at 06:52:01PM -0600, Kevin Locke wrote:
> Although Windows APIs generally permit "/" or "\\" for directory
> separators in paths, cmd.exe does not recognize "./" when invoking
> executables using a relative path and prints the following error:
> 
>     '.' is not recognized as an internal or external command,
>     operable program or batch file.
> 
> Therefore, use "\\" when invoking tests on Windows.
> 
> Signed-off-by: Kevin Locke <[email protected]>

A bit ugly, but I think necessarily so to accomplish the goal.

Reviewed-by: David Gibson <[email protected]>

> ---
>  tools/configurator/configurator.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c
> index 9dcf307..e95fd70 100644
> --- a/tools/configurator/configurator.c
> +++ b/tools/configurator/configurator.c
> @@ -41,6 +41,12 @@
>  #define OUTPUT_FILE "configurator.out"
>  #define INPUT_FILE "configuratortest.c"
>  
> +#ifdef _WIN32
> +#define DIR_SEP   "\\"
> +#else
> +#define DIR_SEP   "/"
> +#endif
> +
>  static const char *progname = "";
>  static int verbose;
>  
> @@ -615,7 +621,7 @@ static bool run_test(const char *cmd, struct test *test)
>  		free(output);
>  		/* We run INSIDE_MAIN tests for sanity checking. */
>  		if ((test->style & EXECUTE) || (test->style & INSIDE_MAIN)) {
> -			output = run("./" OUTPUT_FILE, &status);
> +			output = run("." DIR_SEP OUTPUT_FILE, &status);
>  			if (!(test->style & EXECUTE) && status != 0)
>  				errx(1, "Test for %s failed with %i:\n%s",
>  				     test->name, status, output);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

_______________________________________________
ccan mailing list
[email protected]
https://lists.ozlabs.org/listinfo/ccan
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJX4MNcAAoJEGw4ysog2bOSM00P+QGtJZ0vRdHswpuSFXwga+fx
XVmCSw3b7lkSjlv8AetXtsvGoes1dlsNOL/m+s7XbGeVMGLtweFBZ3bPZJCfJbC+
HvZKCTMyDd+06dWFglbLXKX35X7+v1BBFgQdAy/u6l7aPTVzkxJT/oVE+4uQPEPK
osxQqcXz8TgHDeBUxZ2JMaQxmFpgGtHxXuckWzOssQsWyY6mzh/kxSwNR3U9nPWP
JI9DvMGD4TtSbTMnDGt60O5izhwE69GojtqjIaqeA3F/JaYbLfsy+b51WWewCVxM
ccVgjDLjAIKW0EBb+p9FkDAaX10Nn5Agff0Tyy7EJrZcox6VQiL3JMWbrcKGBOIP
EttR5g7l46LxmV4giJCPiPKGO20SIDJ5L+TEYxnuTuGhTGZp05sQddSqUQ7vqQ7J
1Km1TaJYcuCKswRSSrog9VHAdrTroiYKSE94M70GDXh0844g4ZjHsK/TBVHSoExJ
/tDP/7PeNKXAXJBK+mFXsVhPt5C0zWjPKKErn8gYDorXL8cKZp4MVlYPU6iOomAl
v5001In9ntQA4K9VE9uksgMaq2HSkddXv/wwlobFp9X6FOdllrWzil/D+iT3SyfG
+UqluEAJdi1upv9rlRTZgvFNPV2GEb1U/24W2bKU11c26fwtvQDmg7iDRLcvTOLz
+jDgvPCOCUPAmaVpqbRZ
=QMGH
-----END PGP SIGNATURE-----