frysk.sys
Class TestFileDescriptor

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by frysk.junit.TestCase
              extended by frysk.sys.TestFileDescriptor
All Implemented Interfaces:
Test

public class TestFileDescriptor
extends TestCase

Minimal testing for the FileDescriptor.


Nested Class Summary
private static class TestFileDescriptor.IO
           
 
Field Summary
private  FileDescriptor file
           
private  String hello
           
private  Pipe pipe
           
private  String xxxhelloyyy
           
 
Constructor Summary
TestFileDescriptor()
           
 
Method Summary
private  void assertArrayIndexOutOfBounds(String what, TestFileDescriptor.IO io, byte[] buf, int start, int length)
          Check that an IO operation throws an exception.
private  void assertBecomesReady(FileDescriptor fd)
           
 void setUp()
          Sets up the fixture, for example, open a network connection.
 void tearDown()
          Tears down the fixture, for example, close a network connection.
 void testArrayEOF()
          Test closing a pipe.
 void testArrayIO()
          Test passing arrays of bytes through a pipe.
 void testArraySubBufferRead()
          Test a sub-buffer read.
 void testArraySubBufferWrite()
          Test a sub-buffer write.
 void testByteEOF()
          Test closing a pipe.
 void testByteIO()
          Test passing individual bytes through a pipe.
 void testCreate()
          Try creating a temporary file.
 void testDupPipeOutToIn()
          Try duping the output of a Pipe back to its input.
 void testInputOutputStreams()
          Test input and output streams.
 void testNegativeFileDescriptor()
          See what happens if FileDescriptor is -ve.
 void testOpenEtcPasswd()
          Try opening a random file and reading it.
 void testReadOutOfBounds()
          Try performing IO outside of an array's bounds.
 void testReady()
          Test the ready method, a pipe is only ready if something was written to it.
 void testSeek()
          Try wondering round the file using seeks.
 void testTwiceClosed()
          Try closing things twice; second call should do nothing (i.e., no exception).
 void testWriteOutOfBounds()
           
private  void verifyOutOfBounds(TestFileDescriptor.IO io)
          Try performing OP with various out-of-bounds array parameters.
 
Methods inherited from class frysk.junit.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, getTimeoutMilliseconds, getTimeoutSeconds, missing32or64, unresolved, unresolvedOffUtrace, unresolvedOn32On64, unresolvedOnIA32, unresolvedOnPPC, unresolvedOnUtrace, unresolvedOnx8664, unsupported
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pipe

private Pipe pipe

file

private FileDescriptor file

hello

private final String hello
See Also:
Constant Field Values

xxxhelloyyy

private final String xxxhelloyyy
See Also:
Constant Field Values
Constructor Detail

TestFileDescriptor

public TestFileDescriptor()
Method Detail

setUp

public void setUp()
Description copied from class: TestCase
Sets up the fixture, for example, open a network connection. This method is called before a test is executed.

Overrides:
setUp in class TestCase

tearDown

public void tearDown()
Description copied from class: TestCase
Tears down the fixture, for example, close a network connection. This method is called after a test is executed.

Overrides:
tearDown in class TestCase

assertBecomesReady

private void assertBecomesReady(FileDescriptor fd)

testReady

public void testReady()
Test the ready method, a pipe is only ready if something was written to it.


testByteIO

public void testByteIO()
Test passing individual bytes through a pipe.


testArrayIO

public void testArrayIO()
Test passing arrays of bytes through a pipe.


testArraySubBufferWrite

public void testArraySubBufferWrite()
Test a sub-buffer write.


testArraySubBufferRead

public void testArraySubBufferRead()
Test a sub-buffer read.


testByteEOF

public void testByteEOF()
Test closing a pipe.


testArrayEOF

public void testArrayEOF()
Test closing a pipe.


testInputOutputStreams

public void testInputOutputStreams()
                            throws IOException
Test input and output streams.

Throws:
IOException

testDupPipeOutToIn

public void testDupPipeOutToIn()
                        throws IOException
Try duping the output of a Pipe back to its input.

Throws:
IOException

testOpenEtcPasswd

public void testOpenEtcPasswd()
Try opening a random file and reading it. Looking for an error to be thrown.


assertArrayIndexOutOfBounds

private void assertArrayIndexOutOfBounds(String what,
                                         TestFileDescriptor.IO io,
                                         byte[] buf,
                                         int start,
                                         int length)
Check that an IO operation throws an exception.


verifyOutOfBounds

private void verifyOutOfBounds(TestFileDescriptor.IO io)
Try performing OP with various out-of-bounds array parameters.


testReadOutOfBounds

public void testReadOutOfBounds()
Try performing IO outside of an array's bounds.


testWriteOutOfBounds

public void testWriteOutOfBounds()

testSeek

public void testSeek()
Try wondering round the file using seeks.


testNegativeFileDescriptor

public void testNegativeFileDescriptor()
See what happens if FileDescriptor is -ve.


testTwiceClosed

public void testTwiceClosed()
Try closing things twice; second call should do nothing (i.e., no exception).


testCreate

public void testCreate()
Try creating a temporary file.