tstPath.cpp revision 44368d5e83c7ba97ad7763a1ad193cc4f739b76d
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * IPRT Testcase - Test various path functions.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * available from http://www.virtualbox.org. This file is free software;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * General Public License (GPL) as published by the Free Software
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * The contents of this file may alternatively be used under the terms
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * of the Common Development and Distribution License Version 1.0
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * VirtualBox OSE distribution, in which case the provisions of the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * CDDL are applicable instead of those of the GPL.
b8ae33177906f4130b85b7c861cae0e78ed4859bvboxsync * You may elect to license modified versions of this file under the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * terms and conditions of either the GPL or the CDDL or both.
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync * additional information or have any questions.
4651430e55b9df9726347e3e3968618e540fe729vboxsync/*******************************************************************************
4651430e55b9df9726347e3e3968618e540fe729vboxsync* Header Files *
4651430e55b9df9726347e3e3968618e540fe729vboxsync*******************************************************************************/
025f9c7729f643fb8780153dc0e6f1c76baddd69vboxsync RTPrintf("\ntstPath: FAILED calling " #method " at line %d: rc=%Rrc\n", __LINE__, rc); \
4651430e55b9df9726347e3e3968618e540fe729vboxsync } while (0)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * RTPathProgram, RTPathUserHome and RTProcGetExecutableName.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (RTProcGetExecutableName(szPath, sizeof(szPath)) == szPath)
f2490dbf97c8247439446844458461b00e50beb0vboxsync RTPrintf("tstPath: FAILED - RTProcGetExecutableName\n");
c7a378ed2fbad681c0b674351d698ef20a368935vboxsync * RTPathAbsEx
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync static const char *aInput[] =
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync // NULL, NULL, -- assertion in RTStrToUtf16
c4d6c81bd0de216d0f42db2e477b1d788fbaefb4vboxsync NULL, "\\\\server\\../share", // -- on Win32, GetFullPathName doesn't remove .. here
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync /* the three below use cases should fail with VERR_INVALID_NAME */
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync //NULL, "\\\\server",
c2029891dc7fbce0f08a378d0335568cf9cbb4c5vboxsync //NULL, "\\\\",
c2029891dc7fbce0f08a378d0335568cf9cbb4c5vboxsync //NULL, "\\\\\\something",
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync /* this is not (and I guess should not be) supported, should fail */
482a222498aae619afda0255a7edf4ebda97268cvboxsync ///@todo "\\\\?\\UNC\\base", "/from_root",
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync for (unsigned i = 0; i < RT_ELEMENTS(aInput); i += 2)
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync RTPrintf("tstPath: base={%s}, path={%s}, ", aInput[i], aInput[i + 1]);
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync CHECK_RC(RTPathAbsEx(aInput[i], aInput[i + 1], szPath, sizeof(szPath)));
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync * RTPathStripFilename
c4d6c81bd0de216d0f42db2e477b1d788fbaefb4vboxsync static const char *apszStripFilenameTests[] =
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync for (unsigned i = 0; i < RT_ELEMENTS(apszStripFilenameTests); i += 2)
b8ae33177906f4130b85b7c861cae0e78ed4859bvboxsync const char *pszExpect = apszStripFilenameTests[i + 1];
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync " input: '%s'\n"
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync " output: '%s'\n"
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync "expected: '%s'\n",