@@ -142,21 +142,33 @@ void stat_tests()
142142 }
143143 CHECKSERT (res == 0 , " chdir to subfolder of cwd is ok" );
144144
145+ /* *
146+ If buf is a null pointer, the behavior of getcwd() is unspecified.
147+ http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html
148+
149+ Changed behavior of getcwd to Expect buf isn't nullptr.
150+
151+ TODO: It's nice to have these test cases in there, but it will require
152+ the test to throw on contract violation
153+ **/
154+
155+ /* *
145156 char* nullcwd = getcwd(nullbuf, 0);
146157 printf("getcwd result (nullptr, size 0): %s\n", nullcwd == nullptr ? "NULL" : nullcwd);
147158 if (nullcwd == nullptr)
148- {
149- printf (" getcwd error: %s\n " , strerror (errno));
150- }
159+ {
160+ printf("getcwd error: %s\n", strerror(errno));
161+ }
151162 CHECKSERT(nullcwd == nullptr && errno == EINVAL, "getcwd() with 0-size buffer should fail with EINVAL");
152163
153164 nullcwd = getcwd(nullptr, 1024);
154165 printf("getcwd result (nullptr): %s\n", nullcwd == nullptr ? "NULL" : nullcwd);
155166 if (nullcwd == nullptr)
156- {
157- printf (" getcwd error: %s\n " , strerror (errno));
158- }
167+ {
168+ printf("getcwd error: %s\n", strerror(errno));
169+ }
159170 CHECKSERT(nullcwd == nullptr, "getcwd() with nullptr buffer should fail");
171+ **/
160172
161173 char * shortcwd = getcwd (shortbuf, 4 );
162174 printf (" getcwd result (small buffer): %s\n " , shortcwd == nullptr ? " NULL" : shortcwd);
0 commit comments