# All header files of the project
HDRFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.h")
# All .c files in functions/_PDCLIB that do not have a regression test driver
-INTFILES := _Exit atomax digits open print rename remove seed stdinit strtox_main strtox_prelim
+INTFILES := _Exit atomax digits open print rename seed stdinit strtox_main strtox_prelim
# All object files in the library
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
# All test drivers (.t)
int prev_errno = errno;
int rc;
errno = 0;
- if ( ( ( rc = unlink( filename ) ) != 0 ) && ( errno == EPERM ) )
+ if ( ( ( rc = unlink( filename ) ) != 0 ) && ( errno == EISDIR ) )
{
rc = rmdir( filename );
}
#undef SEEK_SET
#include <_PDCLIB_test.h>
+#include <stdlib.h>
+#include <string.h>
+
int main( void )
{
- TESTCASE( NO_TESTDRIVER );
+ char filename[ L_tmpnam + 6 ] = "touch ";
+ tmpnam( filename + 6 );
+ /* create file */
+ system( filename );
+ /* file is actually readable */
+ TESTCASE( fopen( filename + 6, "r" ) != NULL );
+ /* remove function does not return error */
+ TESTCASE( _PDCLIB_remove( filename + 6 ) == 0 );
+ /* file is no longer readable */
+ TESTCASE( fopen( filename + 6, "r" ) == NULL );
+ /* remove function does return error */
+ TESTCASE( _PDCLIB_remove( filename + 6 ) != 0 );
+ memcpy( filename, "mkdir", 5 );
+ /* create directory */
+ system( filename );
+ /* remove function does not return error */
+ TESTCASE( _PDCLIB_remove( filename + 6 ) == 0 );
+ /* remove function does return error */
+ TESTCASE( _PDCLIB_remove( filename + 6 ) != 0 );
return TEST_RESULTS;
}