Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/bout++.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ const char DEFAULT_DIR[] = "data";

#include <csignal>
#include <ctime>
#include <filesystem>
#include <string>
#include <vector>

#include <sys/stat.h>

// Value passed at compile time
// Used for MD5SUM, BOUT_LOCALE_PATH, and REVISION
#define BUILDFLAG1_(x) #x
Expand All @@ -81,12 +80,6 @@ const char DEFAULT_DIR[] = "data";
#define INDIRECT0_BOUTMAIN(...) INDIRECT1_BOUTMAIN(#__VA_ARGS__)
#define STRINGIFY(a) INDIRECT0_BOUTMAIN(a)

// Define S_ISDIR if not defined by system headers (that is, MSVC)
// Taken from https://github.com/curl/curl/blob/e59540139a398dc70fde6aec487b19c5085105af/lib/curl_setup.h#L748-L751
#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif

#ifdef _MSC_VER
#include <windows.h>
inline auto getpid() -> int { return GetCurrentProcessId(); }
Expand Down Expand Up @@ -506,9 +499,8 @@ auto parseCommandLineArgs(int argc, char** argv) -> CommandLineArgs {
}

void checkDataDirectoryIsAccessible(const std::string& data_dir) {
struct stat test;
if (stat(data_dir.c_str(), &test) == 0) {
if (!S_ISDIR(test.st_mode)) {
if (std::filesystem::exists(data_dir)) {
if (!std::filesystem::is_directory(data_dir)) {
throw BoutException(_("DataDir \"{:s}\" is not a directory\n"), data_dir);
}
} else {
Expand Down
1 change: 1 addition & 0 deletions tests/integrated/test-backtrace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
bout_add_integrated_test(test-backtrace
SOURCES boutexcept.cxx
REQUIRES BOUT_USE_BACKTRACE
CONFLICTS CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
USE_RUNTEST
)
2 changes: 1 addition & 1 deletion tests/integrated/test-bout-override-default-option/runtest
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash

make && ./test-bout-override-default-option
2 changes: 1 addition & 1 deletion tests/integrated/test-code-style/runtest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

#requires not make

Expand Down
39 changes: 23 additions & 16 deletions tests/integrated/test-command-args/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ import os
import re
import shutil
import unittest
import platform


OUTPUT_FILE = "stdout.log" if platform.system() == "FreeBSD" else "stderr.log"


class TestCommandLineArgs(unittest.TestCase):
command = "./command-args 2>stderr.log"
command = "./command-args >stdout.log 2>stderr.log"

def makeDirAndCopyInput(self, path):
os.mkdir(path)
shutil.copy("BOUT.inp", path)

def setUp(self):
try:
os.remove("stderr.log")
os.remove(OUTPUT_FILE)
except OSError:
pass
shutil.rmtree("./data", ignore_errors=True)
Expand All @@ -29,7 +33,7 @@ class TestCommandLineArgs(unittest.TestCase):
def testNoArgumentsNoDirectory(self):
with self.assertRaises(RuntimeError):
launch_safe(self.command, pipe=True, nproc=1, mthread=1)
with open("stderr.log") as f:
with open(OUTPUT_FILE) as f:
contents = f.read()
self.assertIn(
'"data" does not exist',
Expand Down Expand Up @@ -97,7 +101,7 @@ class TestCommandLineArgs(unittest.TestCase):
launch_safe(
self.command + " -d non_existent", pipe=True, nproc=1, mthread=1
)
with open("stderr.log") as f:
with open(OUTPUT_FILE) as f:
contents = f.read()
self.assertIn(
'"non_existent" does not exist',
Expand All @@ -108,7 +112,7 @@ class TestCommandLineArgs(unittest.TestCase):
def testDirectoryArgumentNonDirectory(self):
with self.assertRaises(RuntimeError):
launch_safe(self.command + " -d runtest", pipe=True, nproc=1, mthread=1)
with open("stderr.log") as f:
with open(OUTPUT_FILE) as f:
contents = f.read()
self.assertIn(
'"runtest" is not a directory',
Expand Down Expand Up @@ -175,21 +179,24 @@ class TestCommandLineArgs(unittest.TestCase):
"--foo_flag",
"some:option=value",
]
_, out = launch_safe(
launch_safe(
self.command + " " + " ".join(extra_options), pipe=True, nproc=1, mthread=1
)

command_line_options = None
for line in out.splitlines():
if line.lstrip().startswith("Command line"):
command_line_options = line
with open("stdout.log") as f:
contents = f.read()

for option in extra_options:
self.assertIn(
option,
command_line_options,
msg="FAIL: option {} not printed out".format(option),
)
command_line_options = None
for line in contents.splitlines():
if line.lstrip().startswith("Command line"):
command_line_options = line

for option in extra_options:
self.assertIn(
option,
command_line_options,
msg="FAIL: option {} not printed out".format(option),
)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-compile-examples-petsc/runtest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

#requires: all_tests
#requires: not make
Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-compile-examples/runtest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

#requires: all_tests
#requires: not make
Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-coordinates-initialization/runtest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Cores: 3

Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-drift-instability/qsubcase.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Create a set of runs and submit to a queueing system e.g. Sun Grid Engine
#
Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-include/runtest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

#requires: all_tests
#Requires: not make
Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-interchange-instability/qsubcase.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

QSUB=mpich2sub # Common values are qsub, mpisub
NP=4
Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-stopCheck/runtest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

make || exit

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/test_bout++.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SignalHandlerTest : public ::testing::Test {

using SignalHandlerTestDeathTest = SignalHandlerTest;

#if !defined(__NVCC__)
#if !defined(__NVCC__) and !defined(__FreeBSD__)
TEST_F(SignalHandlerTestDeathTest, SegFault) {
bout::experimental::setupSignalHandler(bout::experimental::defaultSignalHandler);
// This test is *incredibly* expensive, maybe as much as 1s, so only test the one signal
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/sys/test_timer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ TEST(TimerTest, ListAllInfo) {

using namespace ::testing;
EXPECT_THAT(cout_capture.str(), HasSubstr("Timer name |"));
EXPECT_THAT(cout_capture.str(), ContainsRegex("one *| 0\\.\\d+ | 1 | 0\\.\\d+"));
EXPECT_THAT(cout_capture.str(), ContainsRegex("two *| 0 * | 2 | 0\\.\\d+"));
EXPECT_THAT(cout_capture.str(), ContainsRegex("one *| 0\\.[0-9]+ | 1 | 0\\.[0-9]+"));
EXPECT_THAT(cout_capture.str(), ContainsRegex("two *| 0 * | 2 | 0\\.[0-9]+"));
}
#endif
Loading