fix self-test and map load on Windows (avoid mixing dir separators).
add more specific error codes (used at work) This was SVN commit r9462.
This commit is contained in:
parent
e7e2e03bb9
commit
f608b44d1d
@ -245,6 +245,7 @@ VfsPath CColladaManager::GetLoadableFilename(const VfsPath& pathnameNoExtension,
|
||||
ENSURE(ret == INFO::OK);
|
||||
wchar_t realDaeBuf[PATH_MAX];
|
||||
wcscpy_s(realDaeBuf, ARRAY_SIZE(realDaeBuf), realDaePath_.string().c_str());
|
||||
std::replace(realDaeBuf, realDaeBuf+ARRAY_SIZE(realDaeBuf), '\\', '/');
|
||||
const wchar_t* realDaePath = wcsstr(realDaeBuf, L"mods/");
|
||||
|
||||
// cachedPmdVfsPath is "cache/mods/whatever/art/meshes/whatever_{hash}.pmd"
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/XML/RelaxNG.h"
|
||||
|
||||
static OsPath MOD_PATH(DataDir()/"mods/_test.mesh");
|
||||
static OsPath MOD_PATH(DataDir()/"mods"/"_test.mesh");
|
||||
static OsPath CACHE_PATH(DataDir()/"_testcache");
|
||||
|
||||
const OsPath srcDAE(L"collada/sphere.dae");
|
||||
@ -61,7 +61,7 @@ class TestMeshManager : public CxxTest::TestSuite
|
||||
g_VFS = CreateVfs(20*MiB);
|
||||
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", MOD_PATH));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"collada/", DataDir()/"tests/collada", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"collada/", DataDir()/"tests"/"collada", VFS_MOUNT_MUST_EXIST));
|
||||
|
||||
// Mount _testcache onto virtual /cache - don't use the normal cache
|
||||
// directory because that's full of loads of cached files from the
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
DeleteDirectory(DataDir()/"_testcache"); // clean up in case the last test run failed
|
||||
|
||||
m_VFS = CreateVfs(20*MiB);
|
||||
TS_ASSERT_OK(m_VFS->Mount(L"", DataDir()/"mods/_test.tex", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(m_VFS->Mount(L"", DataDir()/"mods"/"_test.tex", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(m_VFS->Mount(L"cache/", DataDir()/"_testcache"));
|
||||
|
||||
tex_codec_register_all();
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
DeleteDirectory(DataDir()/"_testcache"); // clean up in case the last test run failed
|
||||
|
||||
m_VFS = CreateVfs(20*MiB);
|
||||
TS_ASSERT_OK(m_VFS->Mount(L"", DataDir()/"mods/_test.tex", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(m_VFS->Mount(L"", DataDir()/"mods"/"_test.tex", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(m_VFS->Mount(L"cache/", DataDir()/"_testcache"));
|
||||
|
||||
h_mgr_init();
|
||||
|
@ -39,7 +39,7 @@ const int DA_NOT_OUR_MEM = 0x40000000;
|
||||
static Status validate_da(DynArray* da)
|
||||
{
|
||||
if(!da)
|
||||
WARN_RETURN(ERR::INVALID_PARAM);
|
||||
WARN_RETURN(ERR::INVALID_POINTER);
|
||||
// u8* const base = da->base;
|
||||
const size_t max_size_pa = da->max_size_pa;
|
||||
const size_t cur_size = da->cur_size;
|
||||
|
@ -381,7 +381,7 @@ private:
|
||||
lfh_dst += size;
|
||||
lfh_bytes_remaining -= size;
|
||||
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
mutable u8* lfh_dst;
|
||||
|
@ -125,7 +125,7 @@ Status Stream::Feed(const u8* in, size_t inSize)
|
||||
|
||||
m_inConsumed += inConsumed;
|
||||
m_outProduced += outProduced;
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ extern Status GetPathnames(const PIVFS& fs, const VfsPath& path, const wchar_t*
|
||||
* @param pathname full pathname (since FileInfo only gives the name).
|
||||
* @param fileInfo file information
|
||||
* @param cbData user-specified context
|
||||
* @return INFO::CB_CONTINUE on success; any other value will immediately
|
||||
* @return INFO::CONTINUE on success; any other value will immediately
|
||||
* be returned to the caller (no more calls will be forthcoming).
|
||||
*
|
||||
* CAVEAT: pathname and fileInfo are only valid until the function
|
||||
|
@ -146,7 +146,7 @@ struct DefaultCompletedHook
|
||||
/**
|
||||
* called after a block I/O has completed.
|
||||
*
|
||||
* @return INFO::CB_CONTINUE to proceed; any other value will
|
||||
* @return INFO::CONTINUE to proceed; any other value will
|
||||
* be immediately returned by Run.
|
||||
*
|
||||
* allows progress notification and processing data while waiting for
|
||||
@ -154,7 +154,7 @@ struct DefaultCompletedHook
|
||||
**/
|
||||
Status operator()(const u8* UNUSED(block), size_t UNUSED(blockSize)) const
|
||||
{
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
};
|
||||
|
||||
@ -164,7 +164,7 @@ struct DefaultIssueHook
|
||||
/**
|
||||
* called before a block I/O is issued.
|
||||
*
|
||||
* @return INFO::CB_CONTINUE to proceed; any other value will
|
||||
* @return INFO::CONTINUE to proceed; any other value will
|
||||
* be immediately returned by Run.
|
||||
*
|
||||
* allows generating the data to write while waiting for
|
||||
@ -172,7 +172,7 @@ struct DefaultIssueHook
|
||||
**/
|
||||
Status operator()(aiocb& UNUSED(cb)) const
|
||||
{
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
// not yet initialized, or already shutdown
|
||||
static const ModuleInitState UNINITIALIZED = 0; // value documented in header
|
||||
// running user callback - concurrent ModuleInit callers must spin
|
||||
static const ModuleInitState BUSY = INFO::ALREADY_EXISTS; // never returned
|
||||
static const ModuleInitState BUSY = ERR::AGAIN; // never returned
|
||||
// init succeeded; allow shutdown
|
||||
static const ModuleInitState INITIALIZED = INFO::SKIPPED;
|
||||
|
||||
|
@ -798,7 +798,7 @@ int h_get_refcnt(Handle h)
|
||||
{
|
||||
HDATA* hd = h_data_tag(h);
|
||||
if(!hd)
|
||||
WARN_RETURN(ERR::INVALID_PARAM);
|
||||
WARN_RETURN(ERR::INVALID_HANDLE);
|
||||
|
||||
ENSURE(hd->refs); // if there are no refs, how did the caller manage to keep a Handle?!
|
||||
return hd->refs;
|
||||
|
@ -30,7 +30,7 @@ static Status LibErrorFromVorbis(int err)
|
||||
case OV_EBADHEADER:
|
||||
return ERR::CORRUPTED;
|
||||
case OV_EVERSION:
|
||||
return ERR::VERSION;
|
||||
return ERR::INVALID_VERSION;
|
||||
case OV_ENOTAUDIO:
|
||||
return ERR::_1;
|
||||
case OV_EBADPACKET:
|
||||
|
@ -1009,7 +1009,7 @@ static Status snd_data_free(Handle& hsd)
|
||||
* @param hsd Handle to SndData.
|
||||
* @param al_buf buffer name.
|
||||
* @return Status, most commonly:
|
||||
* INFO::CB_CONTINUE = buffer has been returned; more are expected to be available.
|
||||
* INFO::CONTINUE = buffer has been returned; more are expected to be available.
|
||||
* INFO::OK = buffer has been returned but is the last one (EOF).
|
||||
*/
|
||||
static Status snd_data_buf_get(Handle hsd, ALuint& al_buf)
|
||||
@ -1029,7 +1029,7 @@ static Status snd_data_buf_get(Handle hsd, ALuint& al_buf)
|
||||
const size_t size = (size_t)ret;
|
||||
al_buf = al_buf_alloc(data, (ALsizei)size, sd->al_fmt, sd->al_freq);
|
||||
|
||||
return (size < maxBufferSize)? INFO::OK : INFO::CB_CONTINUE;
|
||||
return (size < maxBufferSize)? INFO::OK : INFO::CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
@ -1923,8 +1923,7 @@ Status snd_fade(Handle hvs, float initial_gain, float final_gain,
|
||||
{
|
||||
H_DEREF(hvs, VSrc, vs);
|
||||
|
||||
if(type != FT_LINEAR && type != FT_EXPONENTIAL && type != FT_S_CURVE &&
|
||||
type != FT_ABORT)
|
||||
if(type != FT_LINEAR && type != FT_EXPONENTIAL && type != FT_S_CURVE && type != FT_ABORT)
|
||||
WARN_RETURN(ERR::INVALID_PARAM);
|
||||
|
||||
// special case - set initial value to current gain (see above).
|
||||
|
@ -140,10 +140,10 @@ int tncpy_s(tchar* dst, size_t max_dst_chars, const tchar* src, size_t max_src_c
|
||||
// the MS implementation returns EINVAL and allows dst = 0 if
|
||||
// max_dst_chars = max_src_chars = 0. no mention of this in
|
||||
// 3.6.2.1.1, so don't emulate that behavior.
|
||||
ENFORCE(dst != 0, ERR::INVALID_PARAM, EINVAL);
|
||||
ENFORCE(max_dst_chars != 0, ERR::INVALID_PARAM, EINVAL); // N1031 says ERANGE, MSDN/MSVC says EINVAL
|
||||
ENFORCE(dst != 0, ERR::INVALID_POINTER, EINVAL);
|
||||
ENFORCE(max_dst_chars != 0, ERR::INVALID_SIZE, EINVAL); // N1031 says ERANGE, MSDN/MSVC says EINVAL
|
||||
*dst = '\0'; // in case src ENFORCE is triggered
|
||||
ENFORCE(src != 0, ERR::INVALID_PARAM, EINVAL);
|
||||
ENFORCE(src != 0, ERR::INVALID_POINTER, EINVAL);
|
||||
|
||||
WARN_IF_PTR_LEN(max_dst_chars);
|
||||
WARN_IF_PTR_LEN(max_src_chars);
|
||||
@ -166,7 +166,7 @@ int tncpy_s(tchar* dst, size_t max_dst_chars, const tchar* src, size_t max_src_c
|
||||
if(max_dst_chars <= max_src_chars)
|
||||
{
|
||||
*dst = '\0';
|
||||
ENFORCE(0, ERR::BUF_SIZE, ERANGE);
|
||||
ENFORCE(0, ERR::INVALID_SIZE, ERANGE);
|
||||
}
|
||||
// .. source: success, but still need to null-terminate the destination.
|
||||
*p = '\0';
|
||||
@ -190,8 +190,8 @@ int tcpy_s(tchar* dst, size_t max_dst_chars, const tchar* src)
|
||||
// 0 is returned to indicate success and that <dst> is null-terminated.
|
||||
int tncat_s(tchar* dst, size_t max_dst_chars, const tchar* src, size_t max_src_chars)
|
||||
{
|
||||
ENFORCE(dst != 0, ERR::INVALID_PARAM, EINVAL);
|
||||
ENFORCE(max_dst_chars != 0, ERR::INVALID_PARAM, EINVAL); // N1031 says ERANGE, MSDN/MSVC says EINVAL
|
||||
ENFORCE(dst != 0, ERR::INVALID_POINTER, EINVAL);
|
||||
ENFORCE(max_dst_chars != 0, ERR::INVALID_SIZE, EINVAL); // N1031 says ERANGE, MSDN/MSVC says EINVAL
|
||||
// src is checked in tncpy_s
|
||||
|
||||
// WARN_IF_PTR_LEN not necessary: both max_dst_chars and max_src_chars
|
||||
|
@ -118,25 +118,29 @@ static const StatusDefinition statusDefs[] = {
|
||||
{ INFO::OK, L"(but return value was 0 which indicates success)" },
|
||||
{ ERR::FAIL, L"Function failed (no details available)" },
|
||||
|
||||
{ INFO::CB_CONTINUE, L"Continue (not an error)" },
|
||||
{ INFO::CONTINUE, L"Continue (not an error)" },
|
||||
{ INFO::SKIPPED, L"Skipped (not an error)" },
|
||||
{ INFO::CANNOT_HANDLE, L"Cannot handle (not an error)" },
|
||||
{ INFO::ALL_COMPLETE, L"All complete (not an error)" },
|
||||
{ INFO::ALREADY_EXISTS, L"Already exists (not an error)" },
|
||||
|
||||
{ ERR::LOGIC, L"Logic error in code" },
|
||||
{ ERR::EXCEPTION, L"Caught an exception" },
|
||||
{ ERR::TIMED_OUT, L"Timed out" },
|
||||
{ ERR::REENTERED, L"Single-call function was reentered" },
|
||||
{ ERR::CORRUPTED, L"File/memory data is corrupted" },
|
||||
{ ERR::VERSION, L"Version mismatch" },
|
||||
{ ERR::ABORTED, L"Operation aborted" },
|
||||
|
||||
{ ERR::INVALID_PARAM, L"Invalid function argument", EINVAL},
|
||||
{ ERR::INVALID_HANDLE, L"Invalid Handle (argument)" },
|
||||
{ ERR::BUF_SIZE, L"Buffer argument too small" },
|
||||
{ ERR::INVALID_ALIGNMENT, L"Invalid alignment", EINVAL },
|
||||
{ ERR::INVALID_OFFSET, L"Invalid offset", EINVAL },
|
||||
{ ERR::INVALID_HANDLE, L"Invalid handle", EINVAL },
|
||||
{ ERR::INVALID_POINTER, L"Invalid pointer", EINVAL },
|
||||
{ ERR::INVALID_SIZE, L"Invalid size", EINVAL },
|
||||
{ ERR::INVALID_FLAG, L"Invalid flag", EINVAL },
|
||||
{ ERR::INVALID_PARAM, L"Invalid parameter", EINVAL },
|
||||
{ ERR::INVALID_VERSION, L"Invalid version", EINVAL },
|
||||
|
||||
{ ERR::AGAIN, L"Try again later" },
|
||||
{ ERR::LIMIT, L"Fixed limit exceeded" },
|
||||
{ ERR::AGAIN, L"Try again later", EAGAIN },
|
||||
{ ERR::LIMIT, L"Fixed limit exceeded", E2BIG },
|
||||
{ ERR::NOT_SUPPORTED, L"Function not supported", ENOSYS },
|
||||
{ ERR::NO_MEM, L"Not enough memory", ENOMEM},
|
||||
|
||||
|
@ -321,12 +321,12 @@ extern Status StatusFromErrno();
|
||||
while(0)
|
||||
|
||||
// return expression if it evaluates to something other than
|
||||
// INFO::CB_CONTINUE. use when invoking callbacks.
|
||||
// INFO::CONTINUE. use when invoking callbacks.
|
||||
#define RETURN_IF_NOT_CONTINUE(expression)\
|
||||
do\
|
||||
{\
|
||||
const Status status_ = (expression);\
|
||||
if(status_ != INFO::CB_CONTINUE)\
|
||||
if(status_ != INFO::CONTINUE)\
|
||||
return status_;\
|
||||
}\
|
||||
while(0)
|
||||
@ -356,48 +356,50 @@ extern Status StatusFromErrno();
|
||||
//-----------------------------------------------------------------------------
|
||||
// shared status code definitions
|
||||
|
||||
namespace INFO
|
||||
{
|
||||
namespace INFO {
|
||||
|
||||
const Status OK = 0;
|
||||
|
||||
// note: these values are > 100 to allow multiplexing them with
|
||||
// coroutine return values, which return completion percentage.
|
||||
|
||||
// function is a callback and indicates that it can (but need not
|
||||
// necessarily) be called again.
|
||||
const Status CB_CONTINUE = +100000;
|
||||
// the function (usually a callback) would like to be called again.
|
||||
const Status CONTINUE = +100000;
|
||||
|
||||
// notify caller that nothing was done.
|
||||
const Status SKIPPED = +100001;
|
||||
const Status SKIPPED = +100001;
|
||||
|
||||
// function is incapable of doing the requested task with the given inputs.
|
||||
// this implies SKIPPED, but also conveys a bit more information.
|
||||
const Status CANNOT_HANDLE = +100002;
|
||||
const Status CANNOT_HANDLE = +100002;
|
||||
|
||||
// function is meant to be called repeatedly, and now indicates that
|
||||
// all jobs are complete.
|
||||
const Status ALL_COMPLETE = +100003;
|
||||
const Status ALL_COMPLETE = +100003;
|
||||
|
||||
// (returned e.g. when inserting into container)
|
||||
const Status ALREADY_EXISTS = +100004;
|
||||
} // namespace INFO
|
||||
|
||||
namespace ERR
|
||||
{
|
||||
const Status FAIL = -1;
|
||||
namespace ERR {
|
||||
|
||||
const Status FAIL = -1; // unknown failure
|
||||
|
||||
// general
|
||||
const Status LOGIC = -100010;
|
||||
const Status TIMED_OUT = -100011;
|
||||
const Status REENTERED = -100012;
|
||||
const Status CORRUPTED = -100013;
|
||||
const Status VERSION = -100014;
|
||||
const Status EXCEPTION = -100011;
|
||||
const Status TIMED_OUT = -100012;
|
||||
const Status REENTERED = -100013;
|
||||
const Status CORRUPTED = -100014;
|
||||
const Status ABORTED = -100015;
|
||||
|
||||
// function arguments
|
||||
const Status INVALID_PARAM = -100020;
|
||||
const Status INVALID_HANDLE = -100021;
|
||||
const Status BUF_SIZE = -100022;
|
||||
// invalid values (usually function arguments)
|
||||
const Status INVALID_ALIGNMENT = -100020;
|
||||
const Status INVALID_OFFSET = -100021;
|
||||
const Status INVALID_HANDLE = -100022;
|
||||
const Status INVALID_POINTER = -100023;
|
||||
const Status INVALID_SIZE = -100024;
|
||||
const Status INVALID_FLAG = -100025;
|
||||
const Status INVALID_PARAM = -100026;
|
||||
const Status INVALID_VERSION = -100027;
|
||||
|
||||
// system limitations
|
||||
const Status AGAIN = -100030;
|
||||
@ -441,6 +443,7 @@ namespace ERR
|
||||
const Status _27 = -100127;
|
||||
const Status _28 = -100128;
|
||||
const Status _29 = -100129;
|
||||
|
||||
} // namespace ERR
|
||||
|
||||
#endif // #ifndef INCLUDED_STATUS
|
||||
|
@ -45,7 +45,7 @@ static size_t numCallers;
|
||||
static Status OnFrame(const _tagSTACKFRAME64* frame, uintptr_t UNUSED(cbData))
|
||||
{
|
||||
callers[numCallers++] = (void*)frame->AddrPC.Offset;
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
|
@ -347,7 +347,7 @@ public:
|
||||
// pc is a 'known' function on the allocation hook's back-trace
|
||||
// (e.g. _malloc_dbg and other helper functions)
|
||||
m_knownCallers.Add(pc);
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
bool IsKnownCaller(uintptr_t pc) const
|
||||
@ -696,7 +696,7 @@ private:
|
||||
|
||||
// skip invalid frames
|
||||
if(pc == 0)
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
|
||||
Status ret = m_filter.NotifyOfCaller(pc);
|
||||
// (CallerFilter provokes stack traces of heap functions; if that is
|
||||
@ -710,7 +710,7 @@ private:
|
||||
|
||||
if(!m_filter.IsKnownCaller(pc))
|
||||
m_callers[m_numCallers++] = pc;
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
static Status OnFrame_Trampoline(const STACKFRAME64* frame, uintptr_t cbData)
|
||||
|
@ -428,7 +428,7 @@ Status wdbg_sym_WalkStack(StackFrameCallback cb, uintptr_t cbData, const CONTEXT
|
||||
|
||||
ret = cb(&sf, cbData);
|
||||
// callback is allowing us to continue
|
||||
if(ret == INFO::CB_CONTINUE)
|
||||
if(ret == INFO::CONTINUE)
|
||||
ret = INFO::OK;
|
||||
// callback reports it's done; stop calling it and return that value.
|
||||
// (can be either success or failure)
|
||||
@ -1834,7 +1834,7 @@ static Status dump_frame_cb(const _tagSTACKFRAME64* sf, uintptr_t UNUSED(cbData)
|
||||
pSymEnumSymbolsW(hProcess, base, mask, dump_sym_cb, 0);
|
||||
|
||||
out(L"\r\n");
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ struct _EXCEPTION_POINTERS;
|
||||
* instruction-pointer because dump_frame_cb needs the frame pointer to
|
||||
* locate frame-relative variables)
|
||||
* @param cbData the user-specified value that was passed to wdbg_sym_WalkStack
|
||||
* @return INFO::CB_CONTINUE to continue, anything else to stop immediately
|
||||
* @return INFO::CONTINUE to continue, anything else to stop immediately
|
||||
* and return that value to wdbg_sym_WalkStack's caller.
|
||||
**/
|
||||
typedef Status (*StackFrameCallback)(const _tagSTACKFRAME64* frame, uintptr_t cbData);
|
||||
|
@ -165,10 +165,8 @@ public:
|
||||
cassert(sizeof(wchar_t) == sizeof(WCHAR));
|
||||
const size_t length = fni->FileNameLength / sizeof(WCHAR);
|
||||
Path::String name(fni->FileName, length);
|
||||
// since we watch subtrees, name may contain '\\'. OsPath forbids
|
||||
// mixing directory separators, so convert them all to '/'.
|
||||
std::replace(name.begin(), name.end(), '\\', '/');
|
||||
|
||||
// (NB: name is actually a relative path since we watch entire subtrees)
|
||||
const OsPath pathname = m_path / name;
|
||||
const DirWatchNotification::EType type = TypeFromAction(fni->Action);
|
||||
notifications.push_back(DirWatchNotification(pathname, type));
|
||||
|
@ -161,7 +161,7 @@ static Status mmap_file(void* start, size_t len, int prot, int flags, int fd, of
|
||||
|
||||
HANDLE hFile = HANDLE_from_intptr(_get_osfhandle(fd));
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
WARN_RETURN(ERR::INVALID_PARAM);
|
||||
WARN_RETURN(ERR::INVALID_HANDLE);
|
||||
|
||||
// MapViewOfFileEx will fail if the "suggested" base address is
|
||||
// nonzero but cannot be honored, so wipe out <start> unless MAP_FIXED.
|
||||
|
@ -126,29 +126,34 @@ Status StatusFromWin()
|
||||
{
|
||||
switch(GetLastError())
|
||||
{
|
||||
case ERROR_OUTOFMEMORY:
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
return ERR::NO_MEM;
|
||||
case ERROR_INVALID_HANDLE:
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
case ERROR_BAD_ARGUMENTS:
|
||||
return ERR::INVALID_PARAM;
|
||||
case ERROR_INSUFFICIENT_BUFFER:
|
||||
return ERR::BUF_SIZE;
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return ERR::FILE_ACCESS;
|
||||
case ERROR_NOT_SUPPORTED:
|
||||
case ERROR_CALL_NOT_IMPLEMENTED:
|
||||
case ERROR_PROC_NOT_FOUND:
|
||||
return ERR::NOT_SUPPORTED;
|
||||
case ERROR_BUSY:
|
||||
case WAIT_TIMEOUT:
|
||||
return ERR::AGAIN;
|
||||
case ERROR_OPERATION_ABORTED:
|
||||
return ERR::ABORTED;
|
||||
|
||||
case ERROR_INVALID_HANDLE:
|
||||
return ERR::INVALID_HANDLE;
|
||||
case ERROR_INSUFFICIENT_BUFFER:
|
||||
return ERR::INVALID_SIZE;
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
case ERROR_BAD_ARGUMENTS:
|
||||
return ERR::INVALID_PARAM;
|
||||
|
||||
case ERROR_OUTOFMEMORY:
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
return ERR::NO_MEM;
|
||||
case ERROR_NOT_SUPPORTED:
|
||||
case ERROR_CALL_NOT_IMPLEMENTED:
|
||||
case ERROR_PROC_NOT_FOUND:
|
||||
return ERR::NOT_SUPPORTED;
|
||||
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
return ERR::FILE_NOT_FOUND;
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return ERR::FILE_ACCESS;
|
||||
|
||||
default:
|
||||
return ERR::FAIL;
|
||||
}
|
||||
|
@ -179,39 +179,41 @@ public:
|
||||
# define STOP_SKIPPING_ERRORS(expectedCount) (void)0
|
||||
#endif
|
||||
|
||||
SKIP_ERRORS(ERR::INVALID_PARAM);
|
||||
SKIP_ERRORS(ERR::INVALID_POINTER);
|
||||
TEST_CPY(0 ,0,0 , EINVAL,""); // all invalid
|
||||
TEST_CPY(0 ,0,s1, EINVAL,""); // dst = 0, max = 0
|
||||
TEST_CPY(0 ,1,s1, EINVAL,""); // dst = 0, max > 0
|
||||
TEST_CPY(d1,1,0 , EINVAL,""); // src = 0
|
||||
TEST_CPY(d1,0,s1, EINVAL,""); // max_dst_chars = 0
|
||||
STOP_SKIPPING_ERRORS(5);
|
||||
STOP_SKIPPING_ERRORS(4);
|
||||
|
||||
SKIP_ERRORS(ERR::BUF_SIZE);
|
||||
SKIP_ERRORS(ERR::INVALID_SIZE);
|
||||
TEST_CPY(d1,0,s1, EINVAL,""); // max_dst_chars = 0
|
||||
TEST_CPY2(d1,1, s1, ERANGE,"");
|
||||
TEST_CPY2(d1,1, s5, ERANGE,"");
|
||||
TEST_CPY2(d5,5, s5, ERANGE,"");
|
||||
STOP_SKIPPING_ERRORS(3);
|
||||
STOP_SKIPPING_ERRORS(4);
|
||||
|
||||
SKIP_ERRORS(ERR::BUF_SIZE);
|
||||
SKIP_ERRORS(ERR::INVALID_SIZE);
|
||||
TEST_NCPY(d1,1 ,s1,1, ERANGE,"");
|
||||
TEST_NCPY(d1,1 ,s5,1, ERANGE,"");
|
||||
TEST_NCPY(d5,5 ,s5,5, ERANGE,"");
|
||||
STOP_SKIPPING_ERRORS(3);
|
||||
|
||||
SKIP_ERRORS(ERR::INVALID_PARAM);
|
||||
SKIP_ERRORS(ERR::INVALID_POINTER);
|
||||
TEST_CAT(0 ,0,0 , EINVAL,""); // all invalid
|
||||
TEST_CAT(0 ,0,s1, EINVAL,""); // dst = 0, max = 0
|
||||
TEST_CAT(0 ,1,s1, EINVAL,""); // dst = 0, max > 0
|
||||
TEST_CAT(d1,1,0 , EINVAL,""); // src = 0
|
||||
STOP_SKIPPING_ERRORS(4);
|
||||
SKIP_ERRORS(ERR::INVALID_SIZE);
|
||||
TEST_CAT(d1,0,s1, EINVAL,""); // max_dst_chars = 0
|
||||
STOP_SKIPPING_ERRORS(5);
|
||||
STOP_SKIPPING_ERRORS(1);
|
||||
|
||||
SKIP_ERRORS(ERR::STRING_NOT_TERMINATED);
|
||||
TEST_CAT(no_null,5,s1, EINVAL,""); // dst not terminated
|
||||
STOP_SKIPPING_ERRORS(1);
|
||||
|
||||
SKIP_ERRORS(ERR::BUF_SIZE);
|
||||
SKIP_ERRORS(ERR::INVALID_SIZE);
|
||||
TEST_CAT2(d1,1, s1, "",ERANGE,"");
|
||||
TEST_CAT2(d1,1, s5, "",ERANGE,"");
|
||||
TEST_CAT2(d10,10, s10, "",ERANGE,""); // empty, total overflow
|
||||
@ -219,7 +221,7 @@ public:
|
||||
TEST_CAT2(d10,10, s10, "12345",ERANGE,""); // not empty, total overflow
|
||||
STOP_SKIPPING_ERRORS(5);
|
||||
|
||||
SKIP_ERRORS(ERR::BUF_SIZE);
|
||||
SKIP_ERRORS(ERR::INVALID_SIZE);
|
||||
TEST_NCAT(d1,1, s1,1, "",ERANGE,"");
|
||||
TEST_NCAT(d1,1, s5,5, "",ERANGE,"");
|
||||
TEST_NCAT(d10,10, s10,10, "",ERANGE,""); // empty, total overflow
|
||||
|
@ -16,9 +16,10 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "CmdLineArgs.h"
|
||||
|
||||
#include "lib/sysdep/sysdep.h"
|
||||
|
||||
CmdLineArgs::CmdLineArgs(int argc, const char* argv[])
|
||||
{
|
||||
if (argc >= 1)
|
||||
@ -26,7 +27,7 @@ CmdLineArgs::CmdLineArgs(int argc, const char* argv[])
|
||||
std::string arg0(argv[0]);
|
||||
// avoid OsPath complaining about mixing both types of separators,
|
||||
// which happens when running in the VC2010 debugger
|
||||
std::replace(arg0.begin(), arg0.end(), '\\', '/');
|
||||
std::replace(arg0.begin(), arg0.end(), '/', SYS_DIR_SEP);
|
||||
m_Arg0 = arg0;
|
||||
}
|
||||
|
||||
|
@ -86,10 +86,9 @@ Paths::Paths(const CmdLineArgs& args)
|
||||
if(!fs_util::FileExists(pathname))
|
||||
WARN_IF_ERR(StatusFromErrno());
|
||||
|
||||
fs::wpath components = pathname.string();
|
||||
for(size_t i = 0; i < 3; i++) // remove "system/name.exe"
|
||||
components.remove_leaf();
|
||||
return components.string();
|
||||
for(size_t i = 0; i < 2; i++) // remove "system/name.exe"
|
||||
pathname = pathname.Parent();
|
||||
return pathname;
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,6 +85,10 @@ public:
|
||||
|
||||
const char* argv3[] = { "ab/cd\\ef\\gh/../ij" };
|
||||
CmdLineArgs c3(ARRAY_SIZE(argv3), argv3);
|
||||
#if OS_WIN
|
||||
TS_ASSERT_WSTR_EQUALS(c3.GetArg0().string(), L"ab\\cd\\ef\\gh\\..\\ij");
|
||||
#else
|
||||
TS_ASSERT_WSTR_EQUALS(c3.GetArg0().string(), L"ab/cd/ef/gh/../ij");
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ static Status BuildDirEntListCB(const VfsPath& pathname, const FileInfo& UNUSED(
|
||||
|
||||
jsval val = ToJSVal( CStrW(pathname.string()) );
|
||||
JS_SetElement(s->cx, s->filename_array, s->cur_idx++, &val);
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ static LibError LoadFormationThunk( const VfsPath& path, const FileInfo& UNUSED(
|
||||
{
|
||||
CFormationCollection* this_ = (CFormationCollection*)cbData;
|
||||
this_->LoadFile(path);
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
int CFormationCollection::LoadTemplates()
|
||||
|
@ -33,7 +33,7 @@ static LibError LoadTechThunk( const VfsPath& pathname, const FileInfo& UNUSED(f
|
||||
{
|
||||
CTechnologyCollection* this_ = (CTechnologyCollection*)cbData;
|
||||
this_->LoadFile(pathname);
|
||||
return INFO::CB_CONTINUE;
|
||||
return INFO::CONTINUE;
|
||||
}
|
||||
|
||||
int CTechnologyCollection::LoadTechnologies()
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
CXeromyces::Startup();
|
||||
|
||||
g_VFS = CreateVfs(20 * MiB);
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods/public", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods"/"public", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"cache/", DataDir()/"cache"));
|
||||
|
||||
// Need some stuff for terrain movement costs:
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
void setUp()
|
||||
{
|
||||
g_VFS = CreateVfs(20 * MiB);
|
||||
g_VFS->Mount(L"", DataDir()/"mods/public", VFS_MOUNT_MUST_EXIST); // ignore directory-not-found errors
|
||||
g_VFS->Mount(L"", DataDir()/"mods"/"public", VFS_MOUNT_MUST_EXIST); // ignore directory-not-found errors
|
||||
CXeromyces::Startup();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
void setUp()
|
||||
{
|
||||
g_VFS = CreateVfs(20 * MiB);
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods/_test.sim", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods"/"_test.sim", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir()/"_testcache"));
|
||||
CXeromyces::Startup();
|
||||
}
|
||||
@ -221,7 +221,7 @@ public:
|
||||
void setUp()
|
||||
{
|
||||
g_VFS = CreateVfs(20 * MiB);
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods/public", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods"/"public", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir()/"_testcache"));
|
||||
CXeromyces::Startup();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
void setUp()
|
||||
{
|
||||
g_VFS = CreateVfs(20 * MiB);
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods/_test.sim", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods"/"_test.sim", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir()/"_testcache"));
|
||||
CXeromyces::Startup();
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ public:
|
||||
CXeromyces::Startup();
|
||||
|
||||
g_VFS = CreateVfs(20 * MiB);
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods/public", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods"/"public", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"cache/", DataDir()/"cache"));
|
||||
|
||||
CTerrain terrain;
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
void setUp()
|
||||
{
|
||||
g_VFS = CreateVfs(20 * MiB);
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods/_test.sim", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/"mods"/"_test.sim", VFS_MOUNT_MUST_EXIST));
|
||||
TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir()/"_testcache"));
|
||||
CXeromyces::Startup();
|
||||
}
|
||||
@ -130,7 +130,7 @@ public:
|
||||
{
|
||||
CSimulation2 sim(NULL, &m_Terrain);
|
||||
|
||||
TS_ASSERT_OK(CreateDirectories(DataDir()/"mods/_test.sim/simulation/components/hotload/", 0700));
|
||||
TS_ASSERT_OK(CreateDirectories(DataDir()/"mods"/"_test.sim"/"simulation"/"components"/"hotload"/"", 0700));
|
||||
|
||||
copyFile(L"simulation/components/test-hotload1.js", L"simulation/components/hotload/hotload.js");
|
||||
TS_ASSERT_OK(g_VFS->Invalidate(L"simulation/components/hotload/hotload.js"));
|
||||
@ -155,7 +155,7 @@ public:
|
||||
|
||||
TS_ASSERT_EQUALS(static_cast<ICmpTest1*> (sim.QueryInterface(ent, IID_Test1))->GetX(), 1000);
|
||||
|
||||
TS_ASSERT_OK(DeleteDirectory(DataDir()/"mods/_test.sim/simulation/components/hotload/"));
|
||||
TS_ASSERT_OK(DeleteDirectory(DataDir()/"mods"/"_test.sim"/"simulation"/"components"/"hotload"/""));
|
||||
TS_ASSERT_OK(g_VFS->Invalidate(L"simulation/components/hotload/hotload.js"));
|
||||
|
||||
TS_ASSERT_OK(sim.ReloadChangedFile(L"simulation/components/hotload/hotload.js"));
|
||||
|
@ -93,7 +93,7 @@ bool ts_str_contains(const std::wstring& str1, const std::wstring& str2)
|
||||
// available, so we use sys_ExecutablePathname.
|
||||
OsPath DataDir()
|
||||
{
|
||||
return sys_ExecutablePathname().Parent()/"../data";
|
||||
return sys_ExecutablePathname().Parent()/".."/"data";
|
||||
}
|
||||
|
||||
// Script-based testing setup:
|
||||
@ -112,7 +112,7 @@ void ScriptTestSetup(ScriptInterface& ifc)
|
||||
|
||||
// Load the TS_* function definitions
|
||||
// (We don't use VFS because tests might not have the normal VFS paths loaded)
|
||||
OsPath path = DataDir()/"tests/test_setup.js";
|
||||
OsPath path = DataDir()/"tests"/"test_setup.js";
|
||||
std::ifstream ifs(OsString(path).c_str());
|
||||
ENSURE(ifs.good());
|
||||
std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
||||
|
Loading…
Reference in New Issue
Block a user