@@ -22,58 +22,68 @@ int main() {
2222
2323 // Try to print the root directory.
2424 char cwd [100 ];
25- getcwd (cwd , sizeof (cwd ));
25+ char * ret ;
26+ ret = getcwd (cwd , sizeof (cwd ));
27+ assert (ret == cwd );
2628 printf ("Current working dir: %s\n" , cwd );
2729
2830 // Try to switch to /working.
2931 chdir ("working" );
30- getcwd (cwd , sizeof (cwd ));
32+ ret = getcwd (cwd , sizeof (cwd ));
33+ assert (ret == cwd );
3134 printf ("Current working dir: %s\n" , cwd );
3235
3336 // Try to switch back to the root directory.
3437 chdir ("/" );
35- getcwd (cwd , sizeof (cwd ));
38+ ret = getcwd (cwd , sizeof (cwd ));
39+ assert (ret == cwd );
3640 printf ("Current working dir: %s\n" , cwd );
3741
3842 // Try to switch to a subdirectory of working.
3943 chdir ("/working/test" );
40- getcwd (cwd , sizeof (cwd ));
44+ ret = getcwd (cwd , sizeof (cwd ));
45+ assert (ret == cwd );
4146 printf ("Current working dir: %s\n" , cwd );
4247
4348 // Try to switch to a non-existent relative path from subdirectory.
4449 // Changing to working in /working/test should fail.
4550 chdir ("working" );
4651 printf ("Errno: %s\n" , strerror (errno ));
4752 assert (errno == ENOENT );
48- getcwd (cwd , sizeof (cwd ));
53+ ret = getcwd (cwd , sizeof (cwd ));
54+ assert (ret == cwd );
4955 printf ("Current working dir is still: %s\n" , cwd );
5056
5157 // Try to switch back to absolute path /working.
5258 errno = 0 ;
5359 chdir ("/working" );
5460 printf ("Errno: %s\n" , strerror (errno ));
5561 assert (errno == 0 );
56- getcwd (cwd , sizeof (cwd ));
62+ ret = getcwd (cwd , sizeof (cwd ));
63+ assert (ret == cwd );
5764 printf ("Current working dir is now: %s\n" , cwd );
5865
5966 // Try to switch to a non-existent absolute path.
6067 errno = 0 ;
6168 chdir ("/foobar" );
6269 printf ("Errno: %s\n" , strerror (errno ));
6370 assert (errno == ENOENT );
64- getcwd (cwd , sizeof (cwd ));
71+ ret = getcwd (cwd , sizeof (cwd ));
72+ assert (ret == cwd );
6573 printf ("Current working dir is still: %s\n" , cwd );
6674
6775 // Try to switch to /dev.
6876 chdir ("/dev" );
69- getcwd (cwd , sizeof (cwd ));
77+ ret = getcwd (cwd , sizeof (cwd ));
78+ assert (ret == cwd );
7079 printf ("Current working dir: %s\n" , cwd );
7180
7281 // Try to change cwd to a file.
7382 chdir ("/dev/stdout" );
7483 printf ("Errno: %s\n" , strerror (errno ));
7584 assert (errno == ENOTDIR );
76- getcwd (cwd , sizeof (cwd ));
85+ ret = getcwd (cwd , sizeof (cwd ));
86+ assert (ret == cwd );
7787 printf ("Current working dir is still: %s\n" , cwd );
7888
7989 // Try to pass a size of 0.
0 commit comments