mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
* Update spc self to PHP 8.4 only * Update workflows * Fix test-extensions, adjust docs order * Fix cs-fix and phpunit * Add PHP_CS_FIXER_IGNORE_ENV * Add compatibility for PHP 8.3 * Change version description in README, adjust composer.json PHP version limit * Switch PHP to 8.4 in spc-alpine-docker * Add deprecation notice
71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\Tests\builder\linux;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use SPC\builder\linux\SystemUtil;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
class SystemUtilTest extends TestCase
|
|
{
|
|
public static function setUpBeforeClass(): void
|
|
{
|
|
if (PHP_OS_FAMILY !== 'Linux') {
|
|
self::markTestSkipped('This test is only for Linux');
|
|
}
|
|
}
|
|
|
|
public function testIsMuslDistAndGetOSRelease()
|
|
{
|
|
$release = SystemUtil::getOSRelease();
|
|
// we cannot ensure what is the current distro, just test the key exists
|
|
$this->assertArrayHasKey('dist', $release);
|
|
$this->assertArrayHasKey('ver', $release);
|
|
$this->assertTrue($release['dist'] === 'alpine' && SystemUtil::isMuslDist() || $release['dist'] !== 'alpine' && !SystemUtil::isMuslDist());
|
|
}
|
|
|
|
public function testFindStaticLib()
|
|
{
|
|
$this->assertIsArray(SystemUtil::findStaticLib('ld-linux-x86-64.so.2'));
|
|
}
|
|
|
|
public function testGetCpuCount()
|
|
{
|
|
$this->assertIsInt(SystemUtil::getCpuCount());
|
|
}
|
|
|
|
public function testFindHeader()
|
|
{
|
|
$this->assertIsArray(SystemUtil::findHeader('elf.h'));
|
|
}
|
|
|
|
public function testGetCrossCompilePrefix()
|
|
{
|
|
$this->assertIsString(SystemUtil::getCrossCompilePrefix('gcc', 'x86_64'));
|
|
}
|
|
|
|
public function testGetCCType()
|
|
{
|
|
$this->assertEquals('gcc', SystemUtil::getCCType('xjfoiewjfoewof-gcc'));
|
|
}
|
|
|
|
public function testGetSupportedDistros()
|
|
{
|
|
$this->assertIsArray(SystemUtil::getSupportedDistros());
|
|
}
|
|
|
|
public function testFindHeaders()
|
|
{
|
|
$this->assertIsArray(SystemUtil::findHeaders(['elf.h']));
|
|
}
|
|
|
|
public function testFindStaticLibs()
|
|
{
|
|
$this->assertIsArray(SystemUtil::findStaticLibs(['ld-linux-x86-64.so.2']));
|
|
}
|
|
}
|