-
Notifications
You must be signed in to change notification settings - Fork 2
/
Test6.java
49 lines (48 loc) · 1.5 KB
/
Test6.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public class Test6 extends Thread {
private int fd;
public Test6( String[] args ) {
if ( args.length > 0 )
fd = Integer.parseInt( args[0] );
else
fd = 3; // default assumption: the fd used in Test5 was 3
}
public void run() {
SysLib.cout( "Test6.java: fd = " + fd );
byte[] buf16 = new byte[16];
for ( int i = 0; i < 16; i++ )
buf16[i] = ( byte ) i;
byte[] tmpBuf = new byte[16];
int size = SysLib.read( fd, tmpBuf );
if ( size != 16 ) {
SysLib.cout( "Test6.java: size = " + size + "(wrong)" );
SysLib.cout( "fail\n" );
SysLib.exit();
return;
}
for ( int i = 0; i < 16; i++ )
if ( tmpBuf[i] != buf16[i] ) {
SysLib.cout( "Test6.java: tmpBuf[" + i + "] = " + tmpBuf[i] +
" buf16[" + i + "] = " + buf16[i] + " (wrong)\n" );
SysLib.cout( "fail\n" );
SysLib.exit();
return;
}
SysLib.cout( "successfully completed\n" );
SysLib.cout( "Correct behavior of parent/child reading the file...0.5\n" );
//.............................................."
SysLib.cout( "19: uwb1 written by Test6.java..." );
int fd2 = SysLib.open( "uwb1", "w+" );
if ( fd2 == -1 ) {
SysLib.cout( "Test6.java fd2 = -1 (wrong)\n" );
SysLib.cout( "fail\n" );
SysLib.exit();
return;
}
byte[] buf512 = new byte[512];
for ( int i = 0; i < 512; i++ )
buf512[i] = ( byte ) 100;
SysLib.write( fd2, buf512 );
SysLib.close( fd2 );
SysLib.exit();
}
}