fix uv_cwd

This commit is contained in:
Shuhei Tanuma 2012-06-25 13:05:26 +09:00
parent 6e22f44f26
commit 9a0624ecfc
3 changed files with 32 additions and 2 deletions

View File

@ -3005,11 +3005,10 @@ PHP_FUNCTION(uv_cwd)
char buffer[1024] = {0};
size_t buffer_sz = sizeof(buffer);
/* TODO: check behavior */
uv_cwd(buffer, &buffer_sz);
buffer[buffer_sz] = '\0';
RETURN_STRINGL(buffer, buffer_sz, 1);
RETURN_STRING(buffer, 1);
}
/* }}} */

15
tests/999-uv_chdir.phpt Normal file
View File

@ -0,0 +1,15 @@
--TEST--
Check for uv_chdir
--FILE--
<?php
@uv_chdir(); // don't SEGV
uv_chdir(dirname(__FILE__));
if (uv_cwd() == dirname(__FILE__)) {
echo "OK";
} else {
echo "FAILED: expected " . dirname(__FILE__) . ", but " . uv_cwd();
}
--EXPECT--
OK

16
tests/999-uv_cwd.phpt Normal file
View File

@ -0,0 +1,16 @@
--TEST--
Check for uv_cwd
--FILE--
<?php
$cwd = uv_cwd();
$expected = getcwd();
if ($cwd == $expected) {
echo "OK" . PHP_EOL;
} else {
echo "FAILED: expected {$expected}, but {$cwd}" . PHP_EOL;
}
--EXPECT--
OK