Skip to content

Commit

Permalink
parametrize N_DIRS in tests that segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
d3v-null committed Jun 18, 2024
1 parent 20cfff3 commit 86fc688
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/beam/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ fn fee_gpu_beam_values_are_sensible() {
let delays = Array2::zeros((1, 16));
let amps = Array2::ones((1, 16));
let freqs = [150e6 as u32];
// let freqs = (150..181)
// .map(|f| (f as u32 * 1e6 as u32))
// .collect::<Vec<_>>();
let n_dirs = std::env::var("N_DIRS")
.unwrap_or_else(|_| "1025".to_string()) // 192 passes, 193 fails.
.parse::<usize>()
Expand Down
28 changes: 28 additions & 0 deletions src/cli/di_calibrate/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ fn arg_file_relative_globs() {
#[serial]
fn test_1090008640_di_calibrate_writes_solutions() {
let tmp_dir = TempDir::new().expect("couldn't make tmp dir");

let n_dirs = std::env::var("N_DIRS")
.unwrap_or_else(|_| "1025".to_string()) // 192 passes, 193 fails.
.parse::<usize>()
.unwrap();

let DataAsStrings {
metafits,
vis,
Expand All @@ -335,6 +341,7 @@ fn test_1090008640_di_calibrate_writes_solutions() {
"--source-list", &srclist,
"--outputs", &format!("{}", sols.display()),
"--model-filenames", &format!("{}", cal_model.display()),
"--num-sources", &format!("{n_dirs}"),
]);

// Run di-cal and check that it succeeds
Expand Down Expand Up @@ -429,6 +436,11 @@ fn test_1090008640_calibrate_model_uvfits() {
let num_timesteps = 2;
let num_chans = 10;

let n_dirs = std::env::var("N_DIRS")
.unwrap_or_else(|_| "1025".to_string()) // 192 passes, 193 fails.
.parse::<usize>()
.unwrap();

let temp_dir = TempDir::new().expect("couldn't make tmp dir");
let model = temp_dir.path().join("model.uvfits");
let DataAsStrings {
Expand All @@ -442,6 +454,7 @@ fn test_1090008640_calibrate_model_uvfits() {
"--output-model-files", &format!("{}", model.display()),
"--num-timesteps", &format!("{num_timesteps}"),
"--num-fine-channels", &format!("{num_chans}"),
"--num-sources", &format!("{n_dirs}"),
"--veto-threshold", "0.0", // Don't complicate things with vetoing
// The array position is needed because, if not specified, it's read
// slightly different out of the uvfits.
Expand All @@ -462,6 +475,7 @@ fn test_1090008640_calibrate_model_uvfits() {
"--source-list", &srclist,
"--outputs", &format!("{}", sols.display()),
"--model-filenames", &format!("{}", cal_model.display()),
"--num-sources", &format!("{n_dirs}"),
"--veto-threshold", "0.0", // Don't complicate things with vetoing
"--array-position", "116.67081523611111", "-26.703319405555554", "377.827",
]);
Expand Down Expand Up @@ -588,6 +602,11 @@ fn test_1090008640_calibrate_model_ms() {
let num_timesteps = 2;
let num_chans = 10;

let n_dirs = std::env::var("N_DIRS")
.unwrap_or_else(|_| "1025".to_string()) // 192 passes, 193 fails.
.parse::<usize>()
.unwrap();

let temp_dir = TempDir::new().expect("couldn't make tmp dir");
let model = temp_dir.path().join("model.ms");
let DataAsStrings {
Expand All @@ -610,6 +629,7 @@ fn test_1090008640_calibrate_model_ms() {
"--output-model-files", &format!("{}", model.display()),
"--num-timesteps", &format!("{num_timesteps}"),
"--num-fine-channels", &format!("{num_chans}"),
"--num-sources", &format!("{n_dirs}"),
"--array-position",
&format!("{long_deg}"),
&format!("{lat_deg}"),
Expand All @@ -629,6 +649,7 @@ fn test_1090008640_calibrate_model_ms() {
"--source-list", &srclist,
"--outputs", &format!("{}", sols.display()),
"--model-filenames", &format!("{}", cal_model.display()),
"--num-sources", &format!("{n_dirs}"),
"--array-position",
&format!("{long_deg}"),
&format!("{lat_deg}"),
Expand Down Expand Up @@ -735,6 +756,10 @@ fn test_1090008640_calibrate_model_ms() {
fn test_cal_timeblocks() {
let num_timesteps = 3;
let num_chans = 5;
let n_dirs = std::env::var("N_DIRS")
.unwrap_or_else(|_| "1025".to_string()) // 192 passes, 193 fails.
.parse::<usize>()
.unwrap();

let temp_dir = TempDir::new().expect("couldn't make tmp dir");
let model = temp_dir.path().join("model.uvfits");
Expand All @@ -749,6 +774,7 @@ fn test_cal_timeblocks() {
"--output-model-files", &format!("{}", model.display()),
"--num-timesteps", &format!("{num_timesteps}"),
"--num-fine-channels", &format!("{num_chans}"),
"--num-sources", &format!("{n_dirs}"),
"--veto-threshold", "0.0", // Don't complicate things with vetoing
// The array position is needed because, if not specified, it's read
// slightly different out of the uvfits.
Expand All @@ -764,6 +790,7 @@ fn test_cal_timeblocks() {
"--data", &format!("{}", model.display()), &metafits,
"--source-list", &srclist,
"--outputs", &format!("{}", sols_file.display()),
"--num-sources", &format!("{n_dirs}"),
"--veto-threshold", "0.0", // Don't complicate things with vetoing
"--array-position", "116.67081523611111", "-26.703319405555554", "377.827",
]);
Expand All @@ -789,6 +816,7 @@ fn test_cal_timeblocks() {
"--source-list", &srclist,
"--outputs", &format!("{}", sols_file.display()),
"--timesteps-per-timeblock", "2",
"--num-sources", &format!("{n_dirs}"),
"--veto-threshold", "0.0", // Don't complicate things with vetoing
"--array-position", "116.67081523611111", "-26.703319405555554", "377.827",
]);
Expand Down
8 changes: 8 additions & 0 deletions tests/integration_tests/di_calibrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ fn test_1090008640_woden() {
let tmp_dir = TempDir::new().expect("couldn't make tmp dir");
let solutions_path = tmp_dir.path().join("sols.bin");

let n_dirs = std::env::var("N_DIRS")
.unwrap_or_else(|_| "1025".to_string()) // 192 passes, 193 fails.
.parse::<usize>()
.unwrap();

// Reading from a uvfits file without a metafits file should fail because
// there's no beam information.
let cmd = hyperdrive()
Expand All @@ -31,6 +36,7 @@ fn test_1090008640_woden() {
.arg("--outputs")
.arg(&format!("{}", solutions_path.display()))
.arg("--no-progress-bars")
.arg(&format!("--num-sources={}", n_dirs))
.ok();
assert!(cmd.is_err());
let (_, stderr) = get_cmd_output(cmd);
Expand All @@ -49,6 +55,7 @@ fn test_1090008640_woden() {
.arg("--outputs")
.arg(&format!("{}", solutions_path.display()))
.arg("--no-progress-bars")
.arg(&format!("--num-sources={}", n_dirs))
.ok();
assert!(cmd.is_ok(), "{:?}", get_cmd_output(cmd));
let (stdout, _) = get_cmd_output(cmd);
Expand Down Expand Up @@ -109,6 +116,7 @@ fn test_1090008640_woden() {
.arg("--outputs")
.arg(&format!("{}", solutions_path.display()))
.arg("--no-progress-bars")
.arg(&format!("--num-sources={}", n_dirs))
.ok();

// Run di-cal and check that it succeeds
Expand Down

0 comments on commit 86fc688

Please sign in to comment.