Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

test: Skip permission-related tests when running as root #436

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/integration/test_uv_load.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <unistd.h>

#include "../../src/byte.h"
#include "../../src/uv.h"
#include "../lib/runner.h"
Expand Down Expand Up @@ -1724,6 +1726,14 @@ TEST(load, closedSegmentWithBadFormat, setUp, tearDown, 0, NULL)
TEST(load, openSegmentWithNoAccessPermission, setUp, tearDown, 0, NULL)
{
struct fixture *f = data;

/* Skip the test when running as root, since EACCES would not be triggered
* in that case. */
if (getuid() == 0) {
SETUP_UV; /* Setup the uv object since teardown expects it. */
return MUNIT_SKIP;
}

APPEND(1, 1);
UNFINALIZE(1, 1, 1);
DirMakeFileUnreadable(f->dir, "open-1");
Expand Down
9 changes: 9 additions & 0 deletions test/unit/test_uv_fs.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <unistd.h>

#include "../../src/uv_fs.h"
#include "../../src/uv_os.h"
#include "../lib/aio.h"
Expand Down Expand Up @@ -312,6 +314,13 @@ TEST(UvFsProbeCapabilities, aio, DirSetUp, DirTearDown, 0, DirAioParams)
TEST(UvFsProbeCapabilities, noAccess, DirSetUp, DirTearDown, 0, NULL)
{
const char *dir = data;

/* Skip the test when running as root, since EACCES would not be triggered
* in that case. */
if (getuid() == 0) {
return MUNIT_SKIP;
}

DirMakeUnexecutable(dir);
PROBE_CAPABILITIES_ERROR(
dir, RAFT_IOERR,
Expand Down
Loading