Skip to content
Snippets Groups Projects
Commit 35aa37d5 authored by phit0's avatar phit0
Browse files

[test] security routine for small (<=64B) *.pvd files

parent 84ca1808
No related branches found
No related tags found
1 merge request!32Resolve "Add security routine for output file import"
...@@ -251,7 +251,6 @@ ogs6_read_output_files <- function(ogs6_obj){ ...@@ -251,7 +251,6 @@ ogs6_read_output_files <- function(ogs6_obj){
while(((length(pvd_paths) == 0) | any(file.size(pvd_paths) <= 64)) & while(((length(pvd_paths) == 0) | any(file.size(pvd_paths) <= 64)) &
difftime(Sys.time(), t0, units = "secs") < 2) { difftime(Sys.time(), t0, units = "secs") < 2) {
Sys.sleep(0.01) Sys.sleep(0.01)
warning("waiting for pvd file ...")
} }
if (((length(pvd_paths) == 0) | any(file.size(pvd_paths) <= 64))) { if (((length(pvd_paths) == 0) | any(file.size(pvd_paths) <= 64))) {
stop("Output file not written out correctly. stop("Output file not written out correctly.
......
...@@ -93,7 +93,18 @@ test_that("Nonexistent *.pvd file yields an appropriate error", { ...@@ -93,7 +93,18 @@ test_that("Nonexistent *.pvd file yields an appropriate error", {
}) })
test_that("Small *.pvd file yields an appropriate error", {
sim_path <- paste0(tmp_dir, "/run_simulation_test")
dir.create(sim_path)
d <- NULL
save(d, file = paste0(sim_path, "/null.pvd"))
# create empty ogs6 object
ogs6_obj <- OGS6$new(sim_name = "sim", sim_path = sim_path)
expect_error(ogs6_read_output_files(ogs6_obj))
unlink(sim_path, recursive = TRUE)
})
#===== Test benchmarks ===== #===== Test benchmarks =====
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment