mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
Tests: Add test coverage for sys$unveil(..) argument validation
This commit is contained in:
parent
baec9e2d2d
commit
fa448456a9
1 changed files with 28 additions and 0 deletions
|
@ -5,8 +5,36 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibTest/TestCase.h>
|
#include <LibTest/TestCase.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
TEST_CASE(test_argument_validation)
|
||||||
|
{
|
||||||
|
auto res = unveil("/etc", "aaaaaaaaaaaa");
|
||||||
|
EXPECT_EQ(res, -1);
|
||||||
|
EXPECT_EQ(errno, EINVAL);
|
||||||
|
|
||||||
|
res = unveil(nullptr, "r");
|
||||||
|
EXPECT_EQ(res, -1);
|
||||||
|
EXPECT_EQ(errno, EINVAL);
|
||||||
|
|
||||||
|
res = unveil("/etc", nullptr);
|
||||||
|
EXPECT_EQ(res, -1);
|
||||||
|
EXPECT_EQ(errno, EINVAL);
|
||||||
|
|
||||||
|
res = unveil("", "r");
|
||||||
|
EXPECT_EQ(res, -1);
|
||||||
|
EXPECT_EQ(errno, EINVAL);
|
||||||
|
|
||||||
|
res = unveil("test", "r");
|
||||||
|
EXPECT_EQ(res, -1);
|
||||||
|
EXPECT_EQ(errno, EINVAL);
|
||||||
|
|
||||||
|
res = unveil("/etc", "f");
|
||||||
|
EXPECT_EQ(res, -1);
|
||||||
|
EXPECT_EQ(errno, EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE(test_failures)
|
TEST_CASE(test_failures)
|
||||||
{
|
{
|
||||||
auto res = unveil("/etc", "r");
|
auto res = unveil("/etc", "r");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue