зеркало из https://github.com/mozilla/gecko-dev.git
Bug 453733 - Software update fails if current directory is root directory (win32 only). r=ted.mielczarek, r=bsmedberg
This commit is contained in:
Родитель
a4e605f065
Коммит
3718d0b8b4
|
@ -1097,14 +1097,24 @@ LaunchWinPostProcess(const WCHAR *appExe)
|
|||
NS_tremove(dlogFile);
|
||||
CopyFile(slogFile, dlogFile, FALSE);
|
||||
|
||||
static int argc = 2;
|
||||
static WCHAR* argv[3] = {
|
||||
L"argv0ignoredbywinlaunchchild",
|
||||
exearg,
|
||||
L"\0"
|
||||
};
|
||||
STARTUPINFOW si = {sizeof(si), 0};
|
||||
PROCESS_INFORMATION pi = {0};
|
||||
|
||||
WinLaunchChild(exefullpath, argc, argv, 0);
|
||||
BOOL ok = CreateProcessW(exefullpath,
|
||||
exearg,
|
||||
NULL, // no special security attributes
|
||||
NULL, // no special thread attributes
|
||||
FALSE, // don't inherit filehandles
|
||||
0, // No special process creation flags
|
||||
NULL, // inherit my environment
|
||||
NULL, // use my current directory
|
||||
&si,
|
||||
&pi);
|
||||
|
||||
if (ok) {
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* the Mozilla Foundation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert Strong <robert.bugzilla@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -65,52 +66,99 @@ BOOL (WINAPI *pCreateProcessWithTokenW)(HANDLE,
|
|||
BOOL (WINAPI *pIsUserAnAdmin)(VOID);
|
||||
|
||||
/**
|
||||
* Get the length that the string will take when it is quoted.
|
||||
* Get the length that the string will take and takes into account the
|
||||
* additional length if the string needs to be quoted and if characters need to
|
||||
* be escaped.
|
||||
*/
|
||||
static int QuotedStrLen(const PRUnichar *s)
|
||||
static int ArgStrLen(const PRUnichar *s)
|
||||
{
|
||||
int i = 2; // initial and final quote
|
||||
while (*s) {
|
||||
if (*s == '"') {
|
||||
++i;
|
||||
}
|
||||
int backslashes = 0;
|
||||
int i = wcslen(s);
|
||||
BOOL hasDoubleQuote = wcschr(s, L'"') != NULL;
|
||||
// Only add doublequotes if the string contains a space or a tab
|
||||
BOOL addDoubleQuotes = wcspbrk(s, L" \t") != NULL;
|
||||
|
||||
++i, ++s;
|
||||
if (addDoubleQuotes) {
|
||||
i += 2; // initial and final duoblequote
|
||||
}
|
||||
|
||||
if (hasDoubleQuote) {
|
||||
while (*s) {
|
||||
if (*s == '\\') {
|
||||
++backslashes;
|
||||
} else {
|
||||
if (*s == '"') {
|
||||
// Escape the doublequote and all backslashes preceding the doublequote
|
||||
i += backslashes + 1;
|
||||
}
|
||||
|
||||
backslashes = 0;
|
||||
}
|
||||
|
||||
++s;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy string "s" to string "d", quoting and escaping all double quotes.
|
||||
* Copy string "s" to string "d", quoting the argument as appropriate and
|
||||
* escaping doublequotes along with any backslashes that immediately precede
|
||||
* duoblequotes.
|
||||
* The CRT parses this to retrieve the original argc/argv that we meant,
|
||||
* see STDARGV.C in the MSVC6 CRT sources.
|
||||
*
|
||||
* @return the end of the string
|
||||
*/
|
||||
static PRUnichar* QuoteString(PRUnichar *d, const PRUnichar *s)
|
||||
static PRUnichar* ArgToString(PRUnichar *d, const PRUnichar *s)
|
||||
{
|
||||
*d = '"';
|
||||
++d;
|
||||
int backslashes = 0;
|
||||
BOOL hasDoubleQuote = wcschr(s, L'"') != NULL;
|
||||
// Only add doublequotes if the string contains a space or a tab
|
||||
BOOL addDoubleQuotes = wcspbrk(s, L" \t") != NULL;
|
||||
|
||||
while (*s) {
|
||||
*d = *s;
|
||||
if (*s == '"') {
|
||||
++d;
|
||||
*d = '"';
|
||||
}
|
||||
|
||||
++d; ++s;
|
||||
if (addDoubleQuotes) {
|
||||
*d = '"'; // initial doublequote
|
||||
++d;
|
||||
}
|
||||
|
||||
*d = '"';
|
||||
++d;
|
||||
if (hasDoubleQuote) {
|
||||
int i;
|
||||
while (*s) {
|
||||
if (*s == '\\') {
|
||||
++backslashes;
|
||||
} else {
|
||||
if (*s == '"') {
|
||||
// Escape the doublequote and all backslashes preceding the doublequote
|
||||
for (i = 0; i <= backslashes; ++i) {
|
||||
*d = '\\';
|
||||
++d;
|
||||
}
|
||||
}
|
||||
|
||||
backslashes = 0;
|
||||
}
|
||||
|
||||
*d = *s;
|
||||
++d; ++s;
|
||||
}
|
||||
} else {
|
||||
wcscpy(d, s);
|
||||
d += wcslen(s);
|
||||
}
|
||||
|
||||
if (addDoubleQuotes) {
|
||||
*d = '"'; // final doublequote
|
||||
++d;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a quoted command from a list of arguments. The returned string
|
||||
* is allocated with "malloc" and should be "free"d.
|
||||
* Creates a command line from a list of arguments. The returned
|
||||
* string is allocated with "malloc" and should be "free"d.
|
||||
*
|
||||
* argv is UTF8
|
||||
*/
|
||||
|
@ -118,10 +166,15 @@ static PRUnichar*
|
|||
MakeCommandLine(int argc, PRUnichar **argv)
|
||||
{
|
||||
int i;
|
||||
int len = 1; // null-termination
|
||||
int len = 0;
|
||||
|
||||
// The + 1 of the last argument handles the allocation for null termination
|
||||
for (i = 0; i < argc; ++i)
|
||||
len += QuotedStrLen(argv[i]) + 1;
|
||||
len += ArgStrLen(argv[i]) + 1;
|
||||
|
||||
// Protect against callers that pass 0 arguments
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
|
||||
PRUnichar *s = (PRUnichar*) malloc(len * sizeof(PRUnichar));
|
||||
if (!s)
|
||||
|
@ -129,9 +182,11 @@ MakeCommandLine(int argc, PRUnichar **argv)
|
|||
|
||||
PRUnichar *c = s;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
c = QuoteString(c, argv[i]);
|
||||
*c = ' ';
|
||||
++c;
|
||||
c = ArgToString(c, argv[i]);
|
||||
if (i + 1 != argc) {
|
||||
*c = ' ';
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
*c = '\0';
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2008
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Robert Strong <robert.bugzilla@gmail.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = test_xulapp
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DIRS += win
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,75 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2008
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Robert Strong <robert.bugzilla@gmail.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = test_xulapp
|
||||
|
||||
REQUIRES = \
|
||||
string \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
TestXREMakeCommandLineWin.cpp \
|
||||
$(NULL)
|
||||
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,comctl32 ws2_32 shell32)
|
||||
|
||||
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
|
||||
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir) \
|
||||
-I$(topsrcdir)/toolkit/xre \
|
||||
-I$(topsrcdir)/config \
|
||||
$(NULL)
|
||||
|
||||
MOZ_WINCONSOLE = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DNS_NO_XPCOM
|
||||
|
||||
libs:: TestXREMakeCommandLineWin.ini
|
||||
$(INSTALL) $^ $(FINAL_TARGET)/
|
||||
|
||||
check::
|
||||
@echo "Running TestXREMakeCommandLineWin tests"
|
||||
@$(RUN_TEST_PROGRAM) $(FINAL_TARGET)/TestXREMakeCommandLineWin.exe
|
|
@ -0,0 +1,265 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert Strong <robert.bugzilla@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
// Support for _setmode
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "nsWindowsRestart.cpp"
|
||||
|
||||
// CommandLineToArgvW may return different values for argv[0] since it contains
|
||||
// the path to the binary that was executed so we prepend an argument that is
|
||||
// quoted with a space to prevent argv[1] being appended to argv[0].
|
||||
#define DUMMY_ARG1 L"\"arg 1\" "
|
||||
|
||||
#define MAXPATHLEN 1024
|
||||
#define LOG_PREFIX L"XRE MakeCommandLine"
|
||||
#define MAX_TESTS 100
|
||||
|
||||
// Verbose output can be enabled by defining VERBOSE 1
|
||||
#define VERBOSE 0
|
||||
|
||||
// Compares compareCmdLine with the output of MakeCommandLine. This is
|
||||
// accomplished by converting inCmdLine to an argument list with
|
||||
// CommandLineToArgvW and converting it back to a command line with
|
||||
// MakeCommandLine.
|
||||
static int
|
||||
verifyCmdLineCreation(PRUnichar *inCmdLine,
|
||||
PRUnichar *compareCmdLine,
|
||||
PRBool passes, int testNum)
|
||||
{
|
||||
int rv = 0;
|
||||
int i;
|
||||
int inArgc;
|
||||
int outArgc;
|
||||
PRBool isEqual;
|
||||
|
||||
// When debugging with command lines containing Unicode characters greater
|
||||
// than 255 you can set the mode for stdout to Unicode so the console will
|
||||
// receive the correct characters though it won't display them properly unless
|
||||
// the console's font has been set to one that can display the characters. You
|
||||
// can also redirect the console output to a file that has been saved as Unicode
|
||||
// to view the characters.
|
||||
// _setmode(_fileno(stdout), _O_WTEXT);
|
||||
|
||||
// Prepend an additional argument to the command line. CommandLineToArgvW
|
||||
// handles argv[0] differently than other arguments since argv[0] is the path
|
||||
// to the binary being executed and MakeCommandLine only handles argv[1] and
|
||||
// larger.
|
||||
PRUnichar *inCmdLineNew = (PRUnichar *) malloc((wcslen(DUMMY_ARG1) + wcslen(inCmdLine) + 1) * sizeof(PRUnichar));
|
||||
wcscpy(inCmdLineNew, DUMMY_ARG1);
|
||||
wcscat(inCmdLineNew, inCmdLine);
|
||||
LPWSTR *inArgv = CommandLineToArgvW(inCmdLineNew, &inArgc);
|
||||
|
||||
PRUnichar *outCmdLine = MakeCommandLine(inArgc - 1, inArgv + 1);
|
||||
PRUnichar *outCmdLineNew = (PRUnichar *) malloc((wcslen(DUMMY_ARG1) + wcslen(outCmdLine) + 1) * sizeof(PRUnichar));
|
||||
wcscpy(outCmdLineNew, DUMMY_ARG1);
|
||||
wcscat(outCmdLineNew, outCmdLine);
|
||||
LPWSTR *outArgv = CommandLineToArgvW(outCmdLineNew, &outArgc);
|
||||
|
||||
if (VERBOSE) {
|
||||
wprintf(L"\n");
|
||||
wprintf(L"Verbose Output\n");
|
||||
wprintf(L"--------------\n");
|
||||
wprintf(L"Input command line : >%s<\n", inCmdLine);
|
||||
wprintf(L"MakeComandLine output: >%s<\n", outCmdLine);
|
||||
wprintf(L"Expected command line: >%s<\n", compareCmdLine);
|
||||
|
||||
wprintf(L"input argc : %d\n", inArgc - 1);
|
||||
wprintf(L"output argc: %d\n", outArgc - 1);
|
||||
|
||||
for (i = 1; i < inArgc; ++i) {
|
||||
wprintf(L"input argv[%d] : >%s<\n", i - 1, inArgv[i]);
|
||||
}
|
||||
|
||||
for (i = 1; i < outArgc; ++i) {
|
||||
wprintf(L"output argv[%d]: >%s<\n", i - 1, outArgv[i]);
|
||||
}
|
||||
wprintf(L"\n");
|
||||
}
|
||||
|
||||
isEqual = (inArgc == outArgc);
|
||||
if (!isEqual) {
|
||||
wprintf(L"*** TEST-%s-FAIL | %s ARGC Comparison | Test %2d\n",
|
||||
passes ? L"UNEXPECTED" : L"KNOWN", LOG_PREFIX, testNum);
|
||||
if (passes) {
|
||||
rv = 1;
|
||||
}
|
||||
LocalFree(inArgv);
|
||||
LocalFree(outArgv);
|
||||
free(inCmdLineNew);
|
||||
free(outCmdLineNew);
|
||||
free(outCmdLine);
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (i = 1; i < inArgc; ++i) {
|
||||
isEqual = (wcscmp(inArgv[i], outArgv[i]) == 0);
|
||||
if (!isEqual) {
|
||||
wprintf(L"*** TEST-%s-FAIL | %s ARGV Comparison | Test %2d\n",
|
||||
passes ? L"UNEXPECTED" : L"KNOWN", LOG_PREFIX, testNum);
|
||||
if (passes) {
|
||||
rv = 1;
|
||||
}
|
||||
LocalFree(inArgv);
|
||||
LocalFree(outArgv);
|
||||
free(inCmdLineNew);
|
||||
free(outCmdLineNew);
|
||||
free(outCmdLine);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
isEqual = (wcscmp(outCmdLine, compareCmdLine) == 0);
|
||||
if (!isEqual) {
|
||||
wprintf(L"*** TEST-%s-FAIL | %s Command Line Comparison | Test %2d\n",
|
||||
passes ? L"UNEXPECTED" : L"KNOWN", LOG_PREFIX, testNum);
|
||||
if (passes) {
|
||||
rv = 1;
|
||||
}
|
||||
LocalFree(inArgv);
|
||||
LocalFree(outArgv);
|
||||
free(inCmdLineNew);
|
||||
free(outCmdLineNew);
|
||||
free(outCmdLine);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (rv == 0) {
|
||||
if (passes) {
|
||||
wprintf(L"*** TEST-PASS | %s | Test %2d\n", LOG_PREFIX, testNum);
|
||||
} else {
|
||||
wprintf(L"*** TEST-UNEXPECTED-PASS | %s | Test %2d\n", LOG_PREFIX, testNum);
|
||||
rv = 1;
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(inArgv);
|
||||
LocalFree(outArgv);
|
||||
free(inCmdLineNew);
|
||||
free(outCmdLineNew);
|
||||
free(outCmdLine);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int wmain(int argc, PRUnichar *argv[])
|
||||
{
|
||||
int i;
|
||||
int rv = 0;
|
||||
|
||||
if (argc > 1 && (_wcsicmp(argv[1], L"-check-one") != 0 ||
|
||||
_wcsicmp(argv[1], L"-check-one") == 0 && argc != 3)) {
|
||||
fwprintf(stderr, L"Displays and validates output from MakeCommandLine.\n\n");
|
||||
fwprintf(stderr, L"Usage: %s -check-one <test number>\n\n", argv[0]);
|
||||
fwprintf(stderr, L" <test number>\tSpecifies the test number to run from the\n");
|
||||
fwprintf(stderr, L"\t\tTestXREMakeCommandLineWin.ini file.\n");
|
||||
return 255;
|
||||
}
|
||||
|
||||
PRUnichar inifile[MAXPATHLEN];
|
||||
if (!::GetModuleFileNameW(0, inifile, MAXPATHLEN)) {
|
||||
wprintf(L"*** TEST-FAIL | %s | GetModuleFileNameW\n", LOG_PREFIX);
|
||||
return 2;
|
||||
}
|
||||
|
||||
WCHAR *slash = wcsrchr(inifile, '\\');
|
||||
if (!slash) {
|
||||
wprintf(L"*** TEST-FAIL | %s | wcsrchr\n", LOG_PREFIX);
|
||||
return 3;
|
||||
}
|
||||
|
||||
wcscpy(slash + 1, L"TestXREMakeCommandLineWin.ini\0");
|
||||
|
||||
for (i = 0; i < MAX_TESTS; ++i) {
|
||||
PRUnichar sInputVal[MAXPATHLEN];
|
||||
PRUnichar sOutputVal[MAXPATHLEN];
|
||||
PRUnichar sPassesVal[MAXPATHLEN];
|
||||
PRUnichar sInputKey[MAXPATHLEN];
|
||||
PRUnichar sOutputKey[MAXPATHLEN];
|
||||
PRUnichar sPassesKey[MAXPATHLEN];
|
||||
|
||||
if (argc > 2 && _wcsicmp(argv[1], L"-check-one") == 0 && argc == 3) {
|
||||
i = _wtoi(argv[2]);
|
||||
}
|
||||
|
||||
_snwprintf(sInputKey, MAXPATHLEN, L"input_%d", i);
|
||||
_snwprintf(sOutputKey, MAXPATHLEN, L"output_%d", i);
|
||||
_snwprintf(sPassesKey, MAXPATHLEN, L"passes_%d", i);
|
||||
|
||||
if (!GetPrivateProfileStringW(L"MakeCommandLineTests", sInputKey, nsnull,
|
||||
sInputVal, MAXPATHLEN, inifile)) {
|
||||
if (i == 0 || argc > 2 && _wcsicmp(argv[1], L"-check-one") == 0) {
|
||||
if (argc > 1 && _wcsicmp(argv[1], L"-check-one") == 0 && argc == 3) {
|
||||
wprintf(L"\nERROR: either the TestXREMakeCommandLineWin.ini file doesn't exist\n");
|
||||
wprintf(L" or the test is not defined in the MakeCommandLineTests section.\n\n");
|
||||
wprintf(L"File: %s\n", inifile);
|
||||
} else {
|
||||
wprintf(L"*** TEST-FAIL | %s\n", LOG_PREFIX);
|
||||
wprintf(L"*** Either the TestXREMakeCommandLineWin.ini file doesn't exist\n");
|
||||
wprintf(L"*** or it has no tests defined in the MakeCommandLineTests section.\n");
|
||||
wprintf(L"*** File: %s\n", inifile);
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
GetPrivateProfileStringW(L"MakeCommandLineTests", sOutputKey, nsnull,
|
||||
sOutputVal, MAXPATHLEN, inifile);
|
||||
GetPrivateProfileStringW(L"MakeCommandLineTests", sPassesKey, nsnull,
|
||||
sPassesVal, MAXPATHLEN, inifile);
|
||||
|
||||
rv |= verifyCmdLineCreation(sInputVal, sOutputVal,
|
||||
(_wcsicmp(sPassesVal, L"false") == 0) ? FALSE : TRUE,
|
||||
i);
|
||||
|
||||
if (argc > 2 && _wcsicmp(argv[1], L"-check-one") == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rv == 0) {
|
||||
wprintf(L"*** TEST-PASS | %s | all tests passed\n", LOG_PREFIX);
|
||||
} else {
|
||||
wprintf(L"*** TEST-FAIL | %s | some tests failed\n", LOG_PREFIX);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
; A typical MakeCommandLine test will contain an input and an output name value
|
||||
; pair. The value for input_xx is the input command line and the value for
|
||||
; output_xx is the expected output command line.
|
||||
;
|
||||
; A test that is known to fail can be added as follows. If the passes_xx name
|
||||
; value pair doesn't exist it defaults to true.
|
||||
; input_99=yabadaba
|
||||
; output_99=doo
|
||||
; passes_99=false
|
||||
;
|
||||
; If a value starts and ends with single or double quotation marks then it must
|
||||
; be enclosed in single or double quotation marks due to GetPrivateProfileString
|
||||
; discarding the outmost quotation marks. See GetPrivateProfileString on MSDN
|
||||
; for more information.
|
||||
; http://msdn.microsoft.com/en-us/library/ms724353.aspx
|
||||
|
||||
[MakeCommandLineTests]
|
||||
input_0=a:\
|
||||
output_0=a:\
|
||||
|
||||
input_1=""a:\""
|
||||
output_1=a:\"
|
||||
|
||||
input_2=""a:\b c""
|
||||
output_2=""a:\b c""
|
||||
|
||||
input_3=""a:\b c\""
|
||||
output_3=""a:\b c\"""
|
||||
|
||||
input_4=""a:\b c\d e""
|
||||
output_4=""a:\b c\d e""
|
||||
|
||||
input_5=""a:\b c\d e\""
|
||||
output_5=""a:\b c\d e\"""
|
||||
|
||||
input_6=""a:\\""
|
||||
output_6=a:\
|
||||
|
||||
input_7="a:\" "b:\c d"
|
||||
output_7=a:\" "b:\c d"
|
||||
|
||||
input_8="a "b:\" "c:\d e""
|
||||
output_8="a "b:\" c:\d" e"
|
||||
|
||||
input_9="abc" d e
|
||||
output_9=abc d e
|
||||
|
||||
input_10="a b c" d e
|
||||
output_10="a b c" d e
|
||||
|
||||
input_11=a\\\b d"e f"g h
|
||||
output_11=a\\\b "de fg" h
|
||||
|
||||
input_12=a b
|
||||
output_12=a b
|
||||
|
||||
input_13=""a b""
|
||||
output_13=""a b""
|
||||
|
||||
input_14=a\\\"b c d
|
||||
output_14=a\\\"b c d
|
||||
|
||||
input_15=a\\\"b c"
|
||||
output_15=a\\\"b c
|
||||
|
||||
input_16=""a\\\b c"
|
||||
output_16=""a\\\b c""
|
||||
|
||||
input_17=\"a
|
||||
output_17=\"a
|
||||
|
||||
input_18=\\"a
|
||||
output_18=\a
|
||||
|
||||
input_19=\\"\\\\"a
|
||||
output_19=\\\a
|
||||
|
||||
input_20=\\"\\\\\"a
|
||||
output_20=\\\\\\\"a
|
||||
|
||||
input_21="a\\\"b c\" d e
|
||||
output_21=""a\\\"b c\" d e""
|
||||
|
||||
input_22=a\\\\\"b c" d e"
|
||||
output_22=a\\\\\"b "c d e"
|
||||
|
||||
input_23=a:\b c\アルファ オメガ\d
|
||||
output_23=a:\b c\アルファ オメガ\d
|
||||
|
||||
input_24=a:\b "c\アルファ オメガ\d"
|
||||
output_24=a:\b "c\アルファ オメガ\d"
|
||||
|
||||
input_25=アルファ オメガ
|
||||
output_25=アルファ オメガ
|
Загрузка…
Ссылка в новой задаче