2008-03-09 12:10:10 +08:00
|
|
|
/* testsuite.cc
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
/* This file implements a driver for performing tests on the file/path
|
|
|
|
translation code in path.cc. This file is meant to be generic, all
|
|
|
|
test harness data is in testsuite.h. */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
2021-04-28 21:54:47 +08:00
|
|
|
#include "path.h"
|
2008-03-09 12:10:10 +08:00
|
|
|
#include "testsuite.h"
|
|
|
|
|
|
|
|
static int curtest;
|
|
|
|
|
|
|
|
/* A replacement for the w32api GetCurrentDirectory() that returns
|
|
|
|
the cwd that the current test specifies. */
|
|
|
|
DWORD
|
|
|
|
testsuite_getcwd (DWORD nBufferLength, LPSTR lpBuffer)
|
|
|
|
{
|
|
|
|
unsigned len = strlen (testsuite_tests[curtest].cwd) + 1;
|
|
|
|
|
|
|
|
/* If the test specified NO_CWD, then it means we should not have
|
|
|
|
needed the CWD for that test as the test was for an absolute path,
|
|
|
|
and so if we see that here return 0, simulating a
|
|
|
|
GetCurrentDirectory() error. */
|
|
|
|
if (strcmp (testsuite_tests[curtest].cwd, NO_CWD) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (nBufferLength >= len)
|
|
|
|
{
|
|
|
|
strcpy (lpBuffer, testsuite_tests[curtest].cwd);
|
|
|
|
return len - 1;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2021-04-28 21:54:47 +08:00
|
|
|
/*
|
|
|
|
A replacement for read_mounts that installs the test mount table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
testsuite_read_mounts (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; test_mount_table[i].posix; i++)
|
|
|
|
{
|
|
|
|
mount_table[i] = test_mount_table[i];
|
|
|
|
}
|
|
|
|
max_mount_entry = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR cygwin_dll_path[32768];
|
2008-03-09 12:10:10 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int numpass = 0;
|
|
|
|
|
|
|
|
for (test_t &t = testsuite_tests[curtest]; t.posix; t = testsuite_tests[++curtest])
|
|
|
|
{
|
|
|
|
char *result = cygpath (t.posix, NULL);
|
|
|
|
bool pass = (strcmp (result, t.win32) == 0);
|
2011-12-18 07:39:47 +08:00
|
|
|
|
2008-03-09 12:10:10 +08:00
|
|
|
if (pass)
|
2011-12-18 07:39:47 +08:00
|
|
|
{
|
|
|
|
numpass++;
|
|
|
|
printf ("test %03d: PASS cwd=%-18s input=%-22s expected+actual=%s\n",
|
|
|
|
curtest, t.cwd, t.posix, result);
|
|
|
|
}
|
2008-03-09 12:10:10 +08:00
|
|
|
else
|
2011-12-18 07:39:47 +08:00
|
|
|
{
|
|
|
|
printf ("test %03d: FAIL cwd=%-18s input=%-29s expected=%-25s actual=%s\n",
|
|
|
|
curtest, t.cwd, t.posix, t.win32, result);
|
|
|
|
}
|
2008-03-09 12:10:10 +08:00
|
|
|
}
|
|
|
|
printf ("\n"
|
2011-12-18 07:39:47 +08:00
|
|
|
"total tests: %d\n"
|
|
|
|
"pass : %d (%.1f%%)\n"
|
|
|
|
"fail : %d (%.1f%%)\n",
|
|
|
|
curtest, numpass, ((float)numpass)/curtest * 100.0F, curtest - numpass,
|
|
|
|
((float)curtest - numpass)/curtest * 100.0F);
|
2008-03-09 12:10:10 +08:00
|
|
|
return (numpass < curtest ? 1 : 0);
|
|
|
|
}
|