Skip to content

Commit 0df8d09

Browse files
committed
testing platform hardware detection made macos compliant, minor code cleanup
1 parent e113e63 commit 0df8d09

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

fdaPDE/src/io/parsing.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ template <typename CharT> struct token_stream {
6767
using pointer = std::add_pointer_t<value_t>;
6868

6969
line_iterator() noexcept = default;
70-
line_iterator(buff_t buff, size_t buff_sz, size_t begin, size_t end, char sep) :
71-
buff_(buff), sep_(sep), token_sz_(0), buff_sz_(buff_sz), begin_(begin), end_(end), pos_(0) {
70+
line_iterator(buff_t buff, size_t begin, size_t end, char sep) :
71+
buff_(buff), sep_(sep), token_sz_(0), begin_(begin), end_(end), pos_(0) {
7272
fetch_token_();
7373
}
7474
bool has_token() const { return has_token_; }
@@ -105,7 +105,7 @@ template <typename CharT> struct token_stream {
105105
value_t token_;
106106
const buff_t buff_ = nullptr;
107107
char sep_;
108-
size_t token_sz_, buff_sz_;
108+
size_t token_sz_;
109109
size_t begin_, end_, pos_;
110110
mutable bool has_token_ = true;
111111
};
@@ -114,7 +114,7 @@ template <typename CharT> struct token_stream {
114114
head_ = tail_;
115115
tail_ = tail_ + next_char_(buff_, head_, buff_sz_, '\n');
116116
if (tail_ < buff_sz_) { tail_++; }
117-
return line_iterator {buff_, buff_sz_, head_, tail_, sep_};
117+
return line_iterator {buff_, head_, tail_, sep_};
118118
}
119119
bool has_line() const { return head_ < buff_sz_; }
120120
operator bool() const { return head_ < buff_sz_; }

tests/run_tests.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,27 @@ fi
6565
COMPILER_VERSION=$("$CC" --version | head -n1)
6666
CMAKE_VERSION=$(cmake --version | head -n1)
6767

68+
# detect operating system
69+
OSTYPE="$(uname)"
70+
6871
# detect hardware
69-
CPU_MODEL=$(lscpu | grep -m1 "Model name:" | cut -d: -f2- | sed 's/^ *//')
70-
NTHREADS=$(nproc)
71-
THREADS_PER_CORE=$(lscpu | grep -m1 "Thread(s) per core:" | cut -d: -f2 | tr -d ' ')
72+
case "$OSTYPE" in
73+
Linux)
74+
CPU_MODEL=$(lscpu | awk -F: '/Model name/ {sub(/^[ \t]+/, "", $2); print $2; exit}')
75+
NTHREADS=$(nproc)
76+
THREADS_PER_CORE=$(lscpu | awk -F: '/Thread\(s\) per core/ {gsub(/ /,"",$2); print $2; exit}')
77+
;;
78+
Darwin)
79+
CPU_MODEL=$(sysctl -n machdep.cpu.brand_string)
80+
NTHREADS=$(sysctl -n hw.logicalcpu)
81+
THREADS_PER_CORE=$(( $(sysctl -n hw.logicalcpu) / $(sysctl -n hw.physicalcpu) ))
82+
;;
83+
*)
84+
CPU_MODEL="NA"
85+
NTHREADS="NA"
86+
THREADS_PER_CORE="NA"
87+
;;
88+
esac
7289

7390
echo "=============================================="
7491
echo " fdaPDE testing framework"

0 commit comments

Comments
 (0)