diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 4b2d68d..259b471 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -238,3 +238,30 @@ jobs: - name: "Run E2E tests" run: "./e2e/test-finders.sh" + + e2e-ubuntu-restricted: + name: "End-to-End tests Ubuntu (restricted)" + runs-on: "ubuntu-latest" + strategy: + matrix: + php-version: + - "8.1" + steps: + - name: "Checkout" + uses: "actions/checkout@v3.1.0" + + - name: "Set up PHP" + uses: "shivammathur/setup-php@2.22.0" + with: + coverage: "xdebug" + php-version: "${{ matrix.php-version }}" + tools: "phive" + + - name: "Install Composer dependencies" + uses: "ramsey/composer-install@v2" + + - name: "Setup the expected output" + run: "mv e2e/expected-output-ubuntu-restricted e2e/expected-output" + + - name: "Run E2E tests" + run: "./e2e/test-restricted-finders.sh" diff --git a/e2e/expected-output-ubuntu-restricted b/e2e/expected-output-ubuntu-restricted new file mode 100644 index 0000000..d71e9f1 --- /dev/null +++ b/e2e/expected-output-ubuntu-restricted @@ -0,0 +1,13 @@ +CpuInfoFinder: F +DummyCpuCoreFinder(value=1): . +HwLogicalFinder: F +HwPhysicalFinder: F +_NProcessorFinder: F +NProcessorFinder: F +NProcFinder(all=true): F +NProcFinder(all=false): F +NullCpuCoreFinder: F +OnlyOnWindowsFinder(DummyCpuCoreFinder(value=1)): F +SkipOnWindowsFinder(DummyCpuCoreFinder(value=1)): . +WmicPhysicalFinder: F +WmicLogicalFinder: F diff --git a/e2e/test-restricted-finders.sh b/e2e/test-restricted-finders.sh new file mode 100755 index 0000000..5c91d25 --- /dev/null +++ b/e2e/test-restricted-finders.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +execute_finders() { + php -d open_basedir="$(cd .. && pwd):$(php -r 'echo sys_get_temp_dir();')" -d disable_functions="pcntl_exec,pcntl_fork,exec,passthru,proc_open,shell_exec,system,popen" "$(pwd)/e2e/execute-finders.php" 2>&1 +} + +execute_finders > $(pwd)/e2e/actual-output + +diff --ignore-all-space e2e/expected-output e2e/actual-output diff --git a/src/Finder/CpuInfoFinder.php b/src/Finder/CpuInfoFinder.php index 9a5864f..dea4c41 100644 --- a/src/Finder/CpuInfoFinder.php +++ b/src/Finder/CpuInfoFinder.php @@ -73,11 +73,11 @@ public function toString(): string private static function getCpuInfo(): ?string { - if (!is_file(self::CPU_INFO_PATH)) { + if (!@is_file(self::CPU_INFO_PATH)) { return null; } - $cpuInfo = file_get_contents(self::CPU_INFO_PATH); + $cpuInfo = @file_get_contents(self::CPU_INFO_PATH); return false === $cpuInfo ? null