Skip to content

Commit

Permalink
Split of "[Eden] Update lock test to use eden_repo"
Browse files Browse the repository at this point in the history
Summary:
Split of "[Eden] Update test to use eden_repo"

This Diff: Tests for all permissions allowed

Reviewed By: MichaelCuevas

Differential Revision: D65430185

fbshipit-source-id: e3ad2589524c54f6f3fdad54b9f212bf429bb0c9
  • Loading branch information
Chris Dinh authored and facebook-github-bot committed Nov 13, 2024
1 parent 0d871a2 commit 09da90b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions eden/integration/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ python_unittest(
runtime_deps = artifacts["deps"],
deps = [
"//eden/integration/lib:lib",
"//eden/integration/lib:ntapi",
],
)

Expand Down
35 changes: 35 additions & 0 deletions eden/integration/eden_lock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@

import os
import subprocess
import sys

from .lib import testcase

if sys.platform == "win32":
try:
from .lib.ntapi import open_file_handle
except ImportError:
# TODO(T150221518): We should add the ntapi extension module to the
# getdeps build, but for now we have to account for the possibility that
# it may not be present.
pass

GENERIC_READ = 0x80000000
GENERIC_WRITE = 0x40000000
Expand Down Expand Up @@ -87,6 +96,21 @@ def check_commit_remove_blocked(self, errmsg=".*abort:.*") -> None:
):
self.eden_repo.update(self.remove_file_commit)

def _test_share_read_write_delete(self, open_mode) -> None:
# Need to hold open the file until the end of the test
handle = open_file_handle( # noqa: F841
self.repo.get_path(self.BASE_FILE_NAME),
open_mode,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
)

self.check_read_allowed(self.UPDATED_FILE_CONTENTS)
self.check_commit_edit_allowed()
self.check_commit_remove_allowed()

# Handle is closed when it is deleted
del handle

def test_no_lock(self) -> None:
self.check_read_allowed(self.UPDATED_FILE_CONTENTS)
self.check_commit_edit_allowed()
Expand All @@ -95,3 +119,14 @@ def test_no_lock(self) -> None:
self.check_read_allowed(self.UPDATED_FILE_CONTENTS)
self.eden_repo.update(self.add_file_commit)
self.check_read_allowed(self.BASE_FILE_CONTENTS)

def test_read_mode(self) -> None:
# Due to issues with running these tests separately causing resource exhaustion on sockets,
# we need to run them all in the same test. Reset to the default commit before each test.
self._test_share_read_write_delete(b"r")

def test_write_mode(self) -> None:
self._test_share_read_write_delete(b"w")

def test_edit_mode(self) -> None:
self._test_share_read_write_delete(b"+")

0 comments on commit 09da90b

Please sign in to comment.