tstRTSymlink.cpp revision c9579522f347fc3fda6b3f4add0b355981cd7758
/* $Id$ */
/** @file
* IPRT Testcase - Symbolic Links.
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/initterm.h>
{
char szPath1[RTPATH_MAX];
char szPath2[RTPATH_MAX];
/* Create it.*/
/* Check the predicate functions. */
/* Read it. */
RTTESTI_CHECK_MSG(strcmp(szPath2, pszTarget) == 0, ("got=\"%s\" expected=\"%s\"", szPath2, pszTarget));
RTTESTI_CHECK_MSG(strcmp(szPath2, pszTarget) == 0, ("got=\"%s\" expected=\"%s\"", szPath2, pszTarget));
/* Other APIs that have to handle symlinks carefully. */
int rc;
if (RT_SUCCESS(rc))
RTTESTI_CHECK_RC(rc = RTPathQueryInfoEx(szPath1, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK), VINF_SUCCESS);
if (RT_SUCCESS(rc))
if (!fDangling)
{
RTTESTI_CHECK_RC(rc = RTPathQueryInfoEx(szPath1, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK), VINF_SUCCESS);
if (RT_SUCCESS(rc))
else
if (enmType == RTSYMLINKTYPE_DIR)
{
}
else if (enmType == RTSYMLINKTYPE_FILE)
{
}
/** @todo Check more APIs */
}
/* Finally, the removal of the symlink. */
}
{
char szPath1[RTPATH_MAX];
char szPath2[RTPATH_MAX];
/*
* Making some assumptions about how we are executed from to start with...
*/
RTTestISub("Negative RTSymlinkRead, RTSymlinkExists and RTSymlinkIsDangling");
char szExecDir[RTPATH_MAX];
char szExecFile[RTPATH_MAX];
/*
* Do some symlinking. ASSUME they are supported on the test file system.
*/
RTTestISub("Basics");
/*
* Create a few dangling links.
*/
RTTestISub("Dangling links");
}
{
if (rc)
return rc;
return RTTestSummaryAndDestroy(hTest);
}