fix runtime module test
parent
af46bf515f
commit
9193242a76
|
@ -1,13 +1 @@
|
||||||
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
|
|
||||||
// Use of this source code is governed by an MIT license
|
|
||||||
// that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
module runtime
|
module runtime
|
||||||
|
|
||||||
#include <sys/sysinfo.h>
|
|
||||||
|
|
||||||
fn C.get_nprocs() int
|
|
||||||
|
|
||||||
pub fn nr_cpus() int {
|
|
||||||
return C.get_nprocs()
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
|
||||||
|
// Use of this source code is governed by an MIT license
|
||||||
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
module runtime
|
||||||
|
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
|
|
||||||
|
fn C.get_nprocs() int
|
||||||
|
|
||||||
|
pub fn nr_cpus() int {
|
||||||
|
return C.get_nprocs()
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
module runtime
|
||||||
|
|
||||||
|
pub fn nr_cpus() int {
|
||||||
|
return 0
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
import runtime
|
import runtime
|
||||||
|
|
||||||
fn test_nr_cpus() {
|
fn test_nr_cpus() {
|
||||||
|
$if linux {
|
||||||
nr_cpus := runtime.nr_cpus()
|
nr_cpus := runtime.nr_cpus()
|
||||||
println(nr_cpus)
|
println(nr_cpus)
|
||||||
assert nr_cpus > 0
|
assert nr_cpus > 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
module runtime
|
||||||
|
|
||||||
|
pub fn nr_cpus() int {
|
||||||
|
return 0
|
||||||
|
}
|
Loading…
Reference in New Issue