mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
New Read/Write File IO test utility
svn path=/trunk/; revision=957
This commit is contained in:
parent
2001008199
commit
1220167730
2 changed files with 88 additions and 0 deletions
51
reactos/apps/tests/file/Makefile
Normal file
51
reactos/apps/tests/file/Makefile
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
OBJECTS= file.o
|
||||||
|
PROGS= file.exe
|
||||||
|
|
||||||
|
BASE_CFLAGS = -I../../include
|
||||||
|
|
||||||
|
all: $(PROGS)
|
||||||
|
|
||||||
|
.phony: all
|
||||||
|
|
||||||
|
clean:
|
||||||
|
- $(RM) file.o
|
||||||
|
- $(RM) file.exe
|
||||||
|
- $(RM) file.sym
|
||||||
|
|
||||||
|
.phony: clean
|
||||||
|
|
||||||
|
floppy: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||||
|
|
||||||
|
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||||
|
ifeq ($(DOSCLI),yes)
|
||||||
|
$(CP) $* $(FLOPPY_DIR)\apps\$*
|
||||||
|
else
|
||||||
|
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||||
|
endif
|
||||||
|
|
||||||
|
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||||
|
|
||||||
|
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||||
|
ifeq ($(DOSCLI),yes)
|
||||||
|
$(CP) $* ..\..\$(DIST_DIR)\apps\$*
|
||||||
|
else
|
||||||
|
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||||
|
endif
|
||||||
|
|
||||||
|
file.exe: $(OBJECTS)
|
||||||
|
$(CPP) $(OBJECTS) $(BASE_CFLAGS) -o file.exe
|
||||||
|
$(NM) --numeric-sort file.exe > file.sym
|
||||||
|
|
||||||
|
include ../../rules.mak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
37
reactos/apps/tests/file/file.cpp
Normal file
37
reactos/apps/tests/file/file.cpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/***********************************************************
|
||||||
|
* File read/write test utility *
|
||||||
|
**********************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
HANDLE file = CreateFile( "test.dat", GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
|
||||||
|
char buffer[4096];
|
||||||
|
|
||||||
|
if( file == INVALID_HANDLE_VALUE )
|
||||||
|
{
|
||||||
|
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, buffer, 4096, NULL );
|
||||||
|
cout << "Error opening file: " << buffer << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
DWORD wrote;
|
||||||
|
for( int c = 0; c < 1024; c++ )
|
||||||
|
if( WriteFile( file, buffer, 4096, &wrote, NULL ) == FALSE )
|
||||||
|
{
|
||||||
|
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, buffer, 4096, NULL );
|
||||||
|
cout << "Error writing file: " << buffer << endl;
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
cout << "File written, trying to read now" << endl;
|
||||||
|
for( int c = 0; c < 1024; c++ )
|
||||||
|
if( ReadFile( file, buffer, 4096, &wrote, NULL ) == FALSE )
|
||||||
|
{
|
||||||
|
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, buffer, 4096, NULL );
|
||||||
|
cout << "Error reading file: " << buffer << endl;
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
cout << "Test passed" << endl;
|
||||||
|
}
|
Loading…
Reference in a new issue