- Added the fstat() test program.

git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15137 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2006-09-20 19:46:37 +00:00
parent fba16b67fd
commit 36c33073a5
2 changed files with 46 additions and 3 deletions
+7 -3
View File
@@ -1,5 +1,5 @@
#
# $Id: GNUmakefile.68k,v 1.13 2006-08-02 09:22:38 obarthel Exp $
# $Id: GNUmakefile.68k,v 1.14 2006-09-20 19:46:37 obarthel Exp $
#
# :ts=8
#
@@ -49,12 +49,12 @@ LIBS = -lm -lc -lgcc
all: test fgets_test iotest sscanf_test printf_test sprintf_test \
stack_size_test translate_test strtok_test uname simple \
fstat_stdout_test simple_sprintf date_test sscanf_64 factorial \
execvp_test setlocale rand
execvp_test setlocale rand fstat_test
clean:
$(DELETE) #?.o #?.map test fgets_test iotest sscanf_test printf_test \
sprintf_test stack_size_test translate_test strtok_test uname \
simple fstat_stdout_test simple_sprintf date_test sscanf_64 \
simple fstat_stdout_test fstat_test simple_sprintf date_test sscanf_64 \
factorial execvp_test setlocale rand
##############################################################################
@@ -111,6 +111,10 @@ fstat_stdout_test : fstat_stdout_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ fstat_stdout_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
fstat_test : fstat_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ fstat_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
simple_sprintf : simple_sprintf.o
@echo "Linking $@"
$(CC) -nostdlib $(CFLAGS) -o $@ simple_sprintf.o -lc -Wl,--cref,-M,-Map=$@.map
+39
View File
@@ -0,0 +1,39 @@
/*
* $Id: fstat_test.c,v 1.1 2006-09-20 19:46:37 obarthel Exp $
*
* :ts=4
*/
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
/****************************************************************************/
int
main(int argc,char ** argv)
{
struct stat st;
int fd;
if(argc <= 1)
return(EXIT_FAILURE);
fd = open(argv[1],O_RDONLY);
if(fd == -1)
{
perror("open");
return(EXIT_FAILURE);
}
if(fstat(fd,&st) == -1)
{
perror("fstat");
return(EXIT_FAILURE);
}
return(EXIT_SUCCESS);
}