Skip to content

Commit 504f383

Browse files
Merge pull request #658 from nextcloud/fix/os-threads
2 parents d1384c2 + dd38673 commit 504f383

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

lib/OperatingSystems/FreeBSD.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ public function getCpuName(): string {
6262

6363
try {
6464
$model = $this->executeCommand('/sbin/sysctl -n hw.model');
65-
$cores = $this->executeCommand('/sbin/sysctl -n kern.smp.cpus');
65+
$threads = $this->executeCommand('/sbin/sysctl -n kern.smp.cpus');
6666

67-
if ((int)$cores === 1) {
68-
$data = $model . ' (1 core)';
67+
if ((int)$threads === 1) {
68+
$data = $model . ' (1 thread)';
6969
} else {
70-
$data = $model . ' (' . $cores . ' cores)';
70+
$data = $model . ' (' . $threads . ' threads)';
7171
}
7272
} catch (RuntimeException $e) {
7373
return $data;

lib/OperatingSystems/Linux.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ public function getCpuName(): string {
9595
$pattern = '/processor\s+:\s(.+)/';
9696

9797
preg_match_all($pattern, $cpuinfo, $matches);
98-
$cores = count($matches[1]);
98+
$threads = count($matches[1]);
9999

100-
if ($cores === 1) {
101-
$data = $model . ' (1 core)';
100+
if ($threads === 1) {
101+
$data = $model . ' (1 thread)';
102102
} else {
103-
$data = $model . ' (' . $cores . ' cores)';
103+
$data = $model . ' (' . $threads . ' threads)';
104104
}
105105

106106
return $data;

tests/lib/LinuxTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,39 +68,39 @@ public function testGetCpuName(): void {
6868
->with('/proc/cpuinfo')
6969
->willReturn(file_get_contents(__DIR__ . '/../data/linux_cpuinfo'));
7070

71-
$this->assertEquals('Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (4 cores)', $this->os->getCpuName());
71+
$this->assertEquals('Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (4 threads)', $this->os->getCpuName());
7272
}
7373

7474
public function testGetCpuNameOneCore(): void {
7575
$this->os->method('readContent')
7676
->with('/proc/cpuinfo')
7777
->willReturn(file_get_contents(__DIR__ . '/../data/linux_cpuinfo_one_core'));
7878

79-
$this->assertEquals('Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (1 core)', $this->os->getCpuName());
79+
$this->assertEquals('Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (1 thread)', $this->os->getCpuName());
8080
}
8181

8282
public function testGetCpuNamePi3b(): void {
8383
$this->os->method('readContent')
8484
->with('/proc/cpuinfo')
8585
->willReturn(file_get_contents(__DIR__ . '/../data/linux_cpuinfo_pi3b'));
8686

87-
$this->assertEquals('Raspberry Pi 3 Model B Rev 1.2 (4 cores)', $this->os->getCpuName());
87+
$this->assertEquals('Raspberry Pi 3 Model B Rev 1.2 (4 threads)', $this->os->getCpuName());
8888
}
8989

9090
public function testGetCpuNamePi4b(): void {
9191
$this->os->method('readContent')
9292
->with('/proc/cpuinfo')
9393
->willReturn(file_get_contents(__DIR__ . '/../data/linux_cpuinfo_pi4b'));
9494

95-
$this->assertEquals('Raspberry Pi 4 Model B Rev 1.2 (4 cores)', $this->os->getCpuName());
95+
$this->assertEquals('Raspberry Pi 4 Model B Rev 1.2 (4 threads)', $this->os->getCpuName());
9696
}
9797

9898
public function testGetCpuNameOpenPower(): void {
9999
$this->os->method('readContent')
100100
->with('/proc/cpuinfo')
101101
->willReturn(file_get_contents(__DIR__ . '/../data/linux_cpuinfo_openpower'));
102102

103-
$this->assertEquals('POWER9, altivec supported (176 cores)', $this->os->getCpuName());
103+
$this->assertEquals('POWER9, altivec supported (176 threads)', $this->os->getCpuName());
104104
}
105105

106106
public function testGetCpuNameNoData(): void {

0 commit comments

Comments
 (0)