RegressionTests__FileStreamTest.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2225 72fb9427de5b
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2223
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
     1
"{ Encoding: utf8 }"
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
     2
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
69
ffbf7492f5e5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 59
diff changeset
     4
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
118
2618cf1cd493 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 76
diff changeset
     7
TestCase subclass:#FileStreamTest
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	instanceVariableNames:''
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
1079
e4a9fa73a730 category change
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
    11
	category:'tests-Regression-Streams'
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    15
!FileStreamTest methodsFor:'helpers'!
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
332
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    17
createBigDirectoryWithManyFiles
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    18
    "create a directory with 20000 files"
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    19
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    20
    'c:\tmp' asFilename exists ifFalse:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
    21
	'c:\tmp' asFilename makeDirectory
332
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    22
    ].
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    23
    'c:\tmp\BigDirectory' asFilename exists ifFalse:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
    24
	'c:\tmp\BigDirectory' asFilename makeDirectory
332
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    25
    ].
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    26
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    27
    1 to:20000 do:[:i|
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    28
       |f s buffer|
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
    29
       f :='c:\tmp\BigDirectory' asFilename
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
    30
		    construct:(i printString leftPaddedTo:5 with:$0).
332
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    31
       s := f writeStream binary.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
    32
       buffer := ByteArray new:1024.
332
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    33
       32 timesRepeat:[ s nextPutAll:buffer ].
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    34
       s close.
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    35
    ].
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    36
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    37
    "
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    38
     self new createBigDirectoryWithManyFiles
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    39
    "
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    40
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    41
    "Created: / 12.8.1998 / 13:25:25 / cg"
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    42
!
917e3efbdbaa changed #createBigDirectoryWithManyFiles
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
    43
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
createTestFile
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    "create a test file (100k size)"
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    |f bytes|
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
    49
    f := self testFilename writeStream binary.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    bytes := ByteArray new:1024.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    1 to:bytes size do:[:i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
    52
	bytes at:i put:(i \\ 256).
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    ].
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    100 timesRepeat:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
    56
	f nextPutAll:bytes.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    ].
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    f close.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    "
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
    62
     self new createTestFile
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    "Created: / 12.8.1998 / 13:25:25 / cg"
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    68
doTestWrite:size
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
    69
    "Basic writing. Writes a chunk of data and reads it back to verify that
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
    70
     it was written correctly.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
    71
     Called with different sizes and interrupted while writing."
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    72
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    73
    |file s sz buffer byte|
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    74
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    75
    buffer := ByteArray new:size.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    76
    1 to:buffer size do:[:idx |
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
    77
        buffer at:idx put:(idx \\ 256)
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    78
    ].
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    79
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    80
    file := Filename newTemporary.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    81
    s := file writeStream.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    82
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    83
    s binary.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    84
    s nextPutAll:buffer.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    85
    s close.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    86
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    87
    sz := file fileSize.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    88
    sz ~= size ifTrue:[self error:'size mismatch'].
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    89
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    90
    s := file readStream.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    91
    s binary.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    92
    1 to:size do:[:idx |
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
    93
        byte := s next.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
    94
        byte ~~ (idx \\ 256) ifTrue:[self error:'read data mismatch'].
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    95
    ].
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    96
    s close.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    97
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    98
    (file binaryContentsOfEntireFile ~= buffer) ifTrue:[
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
    99
        self error:'read data mismatch2'
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   100
    ].
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   101
    file delete.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   102
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   103
    "
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   104
     self testWrite:1024
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   105
    "
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   106
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   107
    "Modified (comment): / 14-06-2017 / 15:53:07 / mawalch"
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   108
!
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   109
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
readFileExpecting:expect
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    "read test file, expect n bytes"
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    |f buffer n nRead|
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   115
    f := self testFilename readStream binary.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    buffer := ByteArray new:128.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    n := 0.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    [f atEnd] whileFalse:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   120
	nRead := f nextBytes:128 into:buffer.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   121
	n := n + nRead.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    ].
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    f close.
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   124
    self assert:(expect = n) description:('got <1p>; expected:<2p>' expandMacrosWith:n with:expect)
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    "Created: / 12.8.1998 / 13:29:41 / cg"
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    "Modified: / 12.8.1998 / 13:36:40 / cg"
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   128
!
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   129
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   130
testFilename
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   131
    ^ 'testFile' asFilename
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   132
! !
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   133
2173
d4d16e3f15f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1611
diff changeset
   134
!FileStreamTest methodsFor:'initialize / release'!
d4d16e3f15f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1611
diff changeset
   135
d4d16e3f15f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1611
diff changeset
   136
tearDown
d4d16e3f15f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1611
diff changeset
   137
    self testFilename remove
d4d16e3f15f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1611
diff changeset
   138
! !
d4d16e3f15f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1611
diff changeset
   139
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   140
!FileStreamTest methodsFor:'tests'!
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   142
testAppend1
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   143
    "basic open for appending."
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   144
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   145
    |file s sz actualContents expectedContents|
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   146
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   147
    file := Filename newTemporary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   148
    s := file writeStream.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   149
    s binary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   150
    s nextPutAll:(1 to:100).
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   151
    s close.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   152
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   153
    sz := file fileSize.
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   154
    self should:[ sz = 100 ]. "/ size mismatch
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   155
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   156
    s := file appendingWriteStream.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   157
    s binary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   158
    s nextPutAll:(101 to:200).
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   159
    s close.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   160
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   161
    sz := file fileSize.
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   162
    self should:[ sz = 200 ]. "/ size mismatch
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   163
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   164
    actualContents := file binaryContentsOfEntireFile.
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   165
    expectedContents := (1 to:200) asByteArray.
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   166
    self should:[ (actualContents = expectedContents) ].   "/ contents mismatch
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   167
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   168
    file delete.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   169
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   170
    "
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   171
     self new testAppend1
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   172
    "
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   173
!
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   174
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   175
testOpenRead1
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   176
    "basic open for reading."
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   177
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   178
    |sz|
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   179
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   180
    self createTestFile.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   181
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   182
    sz := self testFilename fileSize.
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   183
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   184
    self readFileExpecting:sz.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   185
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   186
    "
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   187
     self new testOpenRead1
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   188
    "
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   189
!
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   190
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   191
testRead1
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    "read a file - check count read with files size."
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    |sz|
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    self createTestFile.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   198
    sz := self testFilename fileSize.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    self readFileExpecting:sz.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    "
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   203
     self new testRead1
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    "
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    "Modified: / 12.8.1998 / 13:29:55 / cg"
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
!
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   209
testRead2
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "read a file - check count read with files size.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
     Do this in 20 threads"
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   213
    |sz verbose errorOccured sema|
651
618563277df4 verbose
Claus Gittinger <cg@exept.de>
parents: 332
diff changeset
   214
618563277df4 verbose
Claus Gittinger <cg@exept.de>
parents: 332
diff changeset
   215
    verbose := false.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    self createTestFile.
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   218
    self assert:(self testFilename exists).
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   220
    sz := self testFilename fileSize.
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   221
    sema := Semaphore new:1-20.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    20 timesRepeat:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   223
	[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   224
	    [
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   225
		self readFileExpecting:sz.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   226
		verbose ifTrue:[ 'done' printCR ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   227
	    ] on:Error do:[:ex|
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   228
		errorOccured := ex.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   229
	    ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   230
	    sema signal.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   231
	] fork.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    ].
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   233
    self assert:(sema waitWithTimeout:20) notNil.
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   234
    self assert:errorOccured isNil.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   237
     self new testRead2
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    "
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
651
618563277df4 verbose
Claus Gittinger <cg@exept.de>
parents: 332
diff changeset
   240
    "Modified: / 10-01-2012 / 19:28:45 / cg"
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
!
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   243
testRead3
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    "read a file - check count read with files size.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
     Do this and interrupt the reading thread heavily"
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   247
    |sz p count nLoop errorOccured|
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    nLoop := 1000.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    self createTestFile.
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   253
    sz := self testFilename fileSize.
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    p := [
2223
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   256
        [
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   257
            nLoop timesRepeat:[
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   258
                self readFileExpecting:sz.
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   259
            ].
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   260
        ] on:Error do:[:ex|
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   261
            errorOccured := ex.
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   262
        ].
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   263
    ] forkAt:(Processor activePriority - 1).
30
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   264
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   265
    count := 0.
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   266
    [p isDead] whileFalse:[
2223
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   267
        Delay waitForMilliseconds:5.
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   268
        p interruptWith:[count := count + 1].
30
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   269
    ].
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   270
    self assert:errorOccured isNil.
2225
72fb9427de5b #BUGFIX by Stefan Reise
sr
parents: 2223
diff changeset
   271
72fb9427de5b #BUGFIX by Stefan Reise
sr
parents: 2223
diff changeset
   272
    "sr: must reduce to 25 because the new test machines run to much faster in IO"
72fb9427de5b #BUGFIX by Stefan Reise
sr
parents: 2223
diff changeset
   273
    self assert:count > 25. "/ at least 25 times interrupted...
72fb9427de5b #BUGFIX by Stefan Reise
sr
parents: 2223
diff changeset
   274
"/    self assert:count > 50. "/ at least 50 times interrupted...
1364
6b667c8faf19 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   275
    "/ Transcript printf:'read file %d times; interrupted %d times\n' with:nLoop with:count.
30
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   276
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   277
    "
119
11246c09ec93 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   278
     self new testRead3
30
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   279
    "
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   280
2223
9368892ee1a7 #BUGFIX by Stefan Reise
sr
parents: 2173
diff changeset
   281
    "Modified: / 12-08-1998 / 13:42:13 / cg"
2225
72fb9427de5b #BUGFIX by Stefan Reise
sr
parents: 2223
diff changeset
   282
    "Modified: / 03-05-2019 / 10:02:20 / Stefan Reise"
30
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   283
!
22531aeb4ce5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   284
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   285
testRewrite1
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   286
    "basic open for writing (with truncation)."
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   287
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   288
    |file s sz|
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   289
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   290
    file := Filename newTemporary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   291
    s := file writeStream.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   292
    s binary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   293
    s nextPutAll:(1 to:200).
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   294
    s close.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   295
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   296
    sz := file fileSize.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   297
    sz ~= 200 ifTrue:[self error:'size mismatch'].
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   298
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   299
    s := file writeStream.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   300
    s binary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   301
    s nextPutAll:(101 to:200).
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   302
    s close.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   303
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   304
    sz := file fileSize.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   305
    sz ~= 100 ifTrue:[self error:'size mismatch'].
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   306
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   307
    (file binaryContentsOfEntireFile ~= (101 to:200) asByteArray) ifTrue:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   308
	self error:'contents mismatch'
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   309
    ].
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   310
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   311
    file delete.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   312
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   313
    "
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   314
     self new testRewrite1
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   315
    "
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   316
!
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   317
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   318
testRewrite2
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   319
    "basic open for re-writing (without truncation)."
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   320
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   321
    |file s sz|
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   322
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   323
    file := Filename newTemporary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   324
    s := file writeStream.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   325
    s binary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   326
    s nextPutAll:(1 to:200).
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   327
    s close.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   328
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   329
    sz := file fileSize.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   330
    sz ~= 200 ifTrue:[self error:'size mismatch'].
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   331
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   332
    s := file readWriteStream.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   333
    s binary.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   334
    s nextPutAll:(101 to:200).
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   335
    s close.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   336
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   337
    sz := file fileSize.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   338
    sz ~= 200 ifTrue:[self error:'size mismatch'].
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   339
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   340
    (file binaryContentsOfEntireFile ~=
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   341
	((101 to:200) asByteArray , (101 to:200) asByteArray)) ifTrue:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   342
	self error:'contents mismatch'
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   343
    ].
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   344
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   345
    file delete.
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   346
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   347
    "
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   348
     self new testRewrite2
75
1a7d48169a36 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 69
diff changeset
   349
    "
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   350
!
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   351
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   352
testWrite1
653
df2012001461 comments
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
   353
    "basic writing in various block sizes"
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   354
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   355
    self doTestWrite:1024.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   356
    self doTestWrite:2048.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   357
    self doTestWrite:4096.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   358
    self doTestWrite:8192.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   359
    self doTestWrite:8192*2.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   360
    self doTestWrite:8192*4.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   361
    self doTestWrite:8192*8.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   362
    self doTestWrite:8192*16.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   363
    self doTestWrite:8192*32.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   364
    self doTestWrite:8192*64.
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   365
    self doTestWrite:8192*128.
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   366
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   367
    "
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   368
     self new testWrite1
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   369
    "
653
df2012001461 comments
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
   370
df2012001461 comments
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
   371
    "Modified (comment): / 18-01-2012 / 12:02:34 / cg"
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   372
!
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   373
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   374
testWrite2
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   375
    "basic writing"
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   376
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   377
    10 timesRepeat:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   378
	self testWrite1.
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   379
    ].
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   380
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   381
    "
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   382
     self new testWrite2
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   383
    "
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   384
!
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   385
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   386
testWrite3
653
df2012001461 comments
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
   387
    "writing with many interrupts"
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   388
923
77b11265aac2 class: RegressionTests::FileStreamTest
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 893
diff changeset
   389
    <timeout: 300>"5 mins"
77b11265aac2 class: RegressionTests::FileStreamTest
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 893
diff changeset
   390
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   391
    |interruptor|
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   392
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   393
    interruptor := [
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   394
	[true] whileTrue:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   395
	    Delay waitForMilliseconds:10.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   396
	].
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   397
    ] forkAt:9.
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   398
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   399
    [
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   400
	50 timesRepeat:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   401
	    self testWrite1.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   402
	].
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   403
    ] valueNowOrOnUnwindDo:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
   404
	interruptor terminate
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   405
    ].
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   406
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   407
    "
120
01f2cb81dc38 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   408
     self new testWrite3
76
90adfa44fa2c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 75
diff changeset
   409
    "
653
df2012001461 comments
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
   410
df2012001461 comments
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
   411
    "Modified (comment): / 18-01-2012 / 12:02:21 / cg"
923
77b11265aac2 class: RegressionTests::FileStreamTest
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 893
diff changeset
   412
    "Modified: / 26-04-2013 / 16:58:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   413
!
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   414
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   415
testWriteEOLModes
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   416
    |testFilename|
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   417
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   418
    testFilename := self testFilename.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   419
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   420
    testFilename writingFileDo:[:s |
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   421
        s eolMode:#crlf.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   422
        s nextPutLine:'hello'
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   423
    ].
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   424
    self assert:(testFilename fileSize == 7).
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   425
    self assert:(testFilename binaryContentsOfEntireFile = #[16r68 16r65 16r6C 16r6C 16r6F 16r0D 16r0A]).
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   426
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   427
    testFilename writingFileDo:[:s |
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   428
        s eolMode:#nl.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   429
        s nextPutLine:'hello'
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   430
    ].
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   431
    self assert:(testFilename fileSize == 6).
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   432
    self assert:(testFilename binaryContentsOfEntireFile = #[16r68 16r65 16r6C 16r6C 16r6F 16r0A]).
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   433
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   434
    testFilename writingFileDo:[:s |
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   435
        s eolMode:#cr.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   436
        s nextPutLine:'hello'
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   437
    ].
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   438
    self assert:(testFilename fileSize == 6).
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   439
    self assert:(testFilename binaryContentsOfEntireFile = #[16r68 16r65 16r6C 16r6C 16r6F 16r0D]).
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   440
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   441
    "/ ------------------------
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   442
1611
7cc93d8bb66f #REFACTORING by mawalch
mawalch
parents: 1610
diff changeset
   443
    testFilename writingFileDo:[:s |
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   444
        s eolMode:#crlf.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   445
        s nextPutAll:'hello' , Character cr
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   446
    ].
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   447
    self assert:(testFilename fileSize == 7).
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   448
    self assert:(testFilename binaryContentsOfEntireFile = #[16r68 16r65 16r6C 16r6C 16r6F 16r0D 16r0A]).
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   449
1611
7cc93d8bb66f #REFACTORING by mawalch
mawalch
parents: 1610
diff changeset
   450
    testFilename writingFileDo:[:s |
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   451
        s eolMode:#nl.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   452
        s nextPutAll:'hello' , Character cr
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   453
    ].
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   454
    self assert:(testFilename fileSize == 6).
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   455
    self assert:(testFilename  binaryContentsOfEntireFile = #[16r68 16r65 16r6C 16r6C 16r6F 16r0A]).
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   456
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   457
    testFilename writingFileDo:[:s |
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   458
        s eolMode:#cr.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   459
        s nextPutAll:'hello' , Character cr
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   460
    ].
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   461
    self assert:(testFilename fileSize == 6).
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   462
    self assert:(testFilename binaryContentsOfEntireFile = #[16r68 16r65 16r6C 16r6C 16r6F 16r0D]).
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   463
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   464
    "/ in binary mode, this should be ignored
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   465
    testFilename writingFileDo:[:s |
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   466
        s binary.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   467
        s eolMode:#crlf.
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   468
        s nextPutAll:'hello' , Character cr
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   469
    ].
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   470
    self assert:(testFilename fileSize == 6).
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   471
    self assert:(testFilename binaryContentsOfEntireFile = #[16r68 16r65 16r6C 16r6C 16r6F 16r0A]).
1268
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   472
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   473
    "
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   474
     self new testWriteEOLModes
f1fed2016730 class: RegressionTests::FileStreamTest
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   475
    "
1610
b98390ab5c37 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   476
1611
7cc93d8bb66f #REFACTORING by mawalch
mawalch
parents: 1610
diff changeset
   477
    "Modified: / 14-06-2017 / 16:08:53 / mawalch"
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
! !
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
!FileStreamTest class methodsFor:'documentation'!
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
version
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
    ^ '$Header$'
1370
c89fedbe5f82 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 1364
diff changeset
   484
!
c89fedbe5f82 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 1364
diff changeset
   485
c89fedbe5f82 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 1364
diff changeset
   486
version_CVS
c89fedbe5f82 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 1364
diff changeset
   487
    ^ '$Header$'
0
cce7631f99b0 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
! !
893
bab45d7a2c6b class: RegressionTests::FileStreamTest
Stefan Vogel <sv@exept.de>
parents: 730
diff changeset
   489