1515
1616int result = 1 ;
1717
18- void success ()
19- {
18+ void success () {
2019 REPORT_RESULT (result );
2120#ifdef FORCE_EXIT
2221 emscripten_force_exit (0 );
2322#endif
2423}
2524
2625void test () {
27-
2826 int fd ;
2927 struct stat st ;
30-
28+
3129#if FIRST
3230
3331 // for each file, we first make sure it doesn't currently exist
@@ -49,22 +47,20 @@ void test() {
4947 fd = open ("/working1/waka.txt" , O_RDWR | O_CREAT , 0666 );
5048 if (fd == -1 )
5149 result = -5000 - errno ;
52- else
53- {
50+ else {
5451 if (write (fd ,"az" ,2 ) != 2 )
5552 result = -6000 - errno ;
5653 if (close (fd ) != 0 )
5754 result = -7000 - errno ;
5855 }
59-
56+
6057 // a file whose contents are random-ish string set by the test_browser.py file
6158 if ((stat ("/working1/moar.txt" , & st ) != -1 ) || (errno != ENOENT ))
6259 result = -8000 - errno ;
6360 fd = open ("/working1/moar.txt" , O_RDWR | O_CREAT , 0666 );
6461 if (fd == -1 )
6562 result = -9000 - errno ;
66- else
67- {
63+ else {
6864 if (write (fd , SECRET , strlen (SECRET )) != strlen (SECRET ))
6965 result = -10000 - errno ;
7066 if (close (fd ) != 0 )
@@ -92,8 +88,7 @@ void test() {
9288 fd = open ("/working1/waka.txt" , O_RDONLY );
9389 if (fd == -1 )
9490 result = -17000 - errno ;
95- else
96- {
91+ else {
9792 char bf [4 ];
9893 int bytes_read = read (fd ,& bf [0 ],sizeof (bf ));
9994 if (bytes_read != 2 )
@@ -105,19 +100,17 @@ void test() {
105100 if (unlink ("/working1/waka.txt" ) != 0 )
106101 result = -21000 - errno ;
107102 }
108-
103+
109104 // does the random-ish file exist and does it contain SECRET?
110105 fd = open ("/working1/moar.txt" , O_RDONLY );
111- if (fd == -1 )
106+ if (fd == -1 ) {
112107 result = -22000 - errno ;
113- else
114- {
108+ } else {
115109 char bf [256 ];
116110 int bytes_read = read (fd ,& bf [0 ],sizeof (bf ));
117- if (bytes_read != strlen (SECRET ))
111+ if (bytes_read != strlen (SECRET )) {
118112 result = -23000 ;
119- else
120- {
113+ } else {
121114 bf [strlen (SECRET )] = 0 ;
122115 if (strcmp (bf ,SECRET ) != 0 )
123116 result = -24000 ;
@@ -129,14 +122,13 @@ void test() {
129122 }
130123
131124 // does the directory exist?
132- if (stat ("/working1/dir" , & st ) != 0 )
125+ if (stat ("/working1/dir" , & st ) != 0 ) {
133126 result = -27000 - errno ;
134- else
135- {
127+ } else {
136128 if (!S_ISDIR (st .st_mode ))
137129 result = -28000 ;
138- if (rmdir ("/working1/dir" ) != 0 )
139- result = -29000 - errno ;
130+ if (rmdir ("/working1/dir" ) != 0 )
131+ result = -29000 - errno ;
140132 }
141133
142134#endif
@@ -164,20 +156,18 @@ void test() {
164156 ccall ('success' , 'v' );
165157 });
166158 );
167-
168159}
169160
170161int main () {
171-
172162 EM_ASM (
173163 FS .mkdir ('/working1' );
174164 FS .mount (IDBFS , {}, '/working1' );
175165
176166#if !FIRST
177- // syncfs(true, f) should not break on already-existing directories:
178- FS .mkdir ('/working1/dir' );
167+ // syncfs(true, f) should not break on already-existing directories:
168+ FS .mkdir ('/working1/dir' );
179169#endif
180-
170+
181171 // sync from persisted state into memory and then
182172 // run the 'test' function
183173 FS .syncfs (true, function (err ) {
@@ -187,6 +177,5 @@ int main() {
187177 );
188178
189179 emscripten_exit_with_live_runtime ();
190-
191180 return 0 ;
192181}
0 commit comments