Skip to content

Commit c9ffbdb

Browse files
committed
fix: improve test infrastructure for 2D correctness and cuFFT reference
- Add test_2d_correctness to pytest CTEST_TARGETS so CI covers 2D tests - check_cufft now throws std::runtime_error instead of printing to stderr, preventing silent reference failures from producing false passes - Replace 2D real transform GTEST_SKIP placeholders with NOT_SUPPORTED assertions (R2C/C2R/D2Z/Z2D are not yet implemented in 2D)
1 parent 97fc825 commit c9ffbdb

3 files changed

Lines changed: 33 additions & 44 deletions

File tree

ctest/test_2d_correctness.cpp

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -366,59 +366,47 @@ INSTANTIATE_TEST_SUITE_P(
366366
k2DBluesteinSizes, sizeof(k2DBluesteinSizes) / sizeof(k2DBluesteinSizes[0]), k2DBatchSingle, 1)));
367367

368368
// =========================================================================
369-
// R2C + C2R 2D roundtrip tests
369+
// R2C/C2R 2D — not yet supported, verify rejection
370370
// =========================================================================
371371

372-
class R2CC2R2D : public ::testing::TestWithParam<Test2DParam> {
373-
protected:
374-
void SetUp() override {
375-
// R2C/C2R 2D not yet supported
376-
}
377-
378-
void TearDown() override {
379-
}
380-
};
381-
382-
TEST_P(R2CC2R2D, Roundtrip) {
383-
GTEST_SKIP() << "R2C/C2R 2D not yet supported";
372+
TEST(Real2D, R2CPlanNotSupported) {
373+
flagfftHandle plan = nullptr;
374+
EXPECT_EQ(flagfftPlan2d(&plan, 64, 32, FLAGFFT_R2C), FLAGFFT_NOT_SUPPORTED);
375+
EXPECT_EQ(plan, nullptr);
384376
}
385377

386-
TEST_P(R2CC2R2D, ForwardReference) {
387-
GTEST_SKIP() << "R2C/C2R 2D not yet supported";
378+
TEST(Real2D, C2RPlanNotSupported) {
379+
flagfftHandle plan = nullptr;
380+
EXPECT_EQ(flagfftPlan2d(&plan, 64, 32, FLAGFFT_C2R), FLAGFFT_NOT_SUPPORTED);
381+
EXPECT_EQ(plan, nullptr);
388382
}
389383

390-
INSTANTIATE_TEST_SUITE_P(Smoke, R2CC2R2D, ::testing::Values(Test2DParam {16, 16, 1}));
391-
392-
INSTANTIATE_TEST_SUITE_P(Extended,
393-
R2CC2R2D,
394-
::testing::ValuesIn(Generate2DParams(k2DSizes, k2DNumSizes, k2DBatchSingle, 1)));
395-
396-
// =========================================================================
397-
// D2Z + Z2D 2D roundtrip tests
398-
// =========================================================================
399-
400-
class D2ZZ2D2D : public ::testing::TestWithParam<Test2DParam> {
401-
protected:
402-
void SetUp() override {
403-
// D2Z/Z2D 2D not yet supported
404-
}
405-
406-
void TearDown() override {
407-
}
408-
};
409-
410-
TEST_P(D2ZZ2D2D, Roundtrip) {
411-
GTEST_SKIP() << "D2Z/Z2D 2D not yet supported";
384+
TEST(Real2D, D2ZPlanNotSupported) {
385+
flagfftHandle plan = nullptr;
386+
EXPECT_EQ(flagfftPlan2d(&plan, 64, 32, FLAGFFT_D2Z), FLAGFFT_NOT_SUPPORTED);
387+
EXPECT_EQ(plan, nullptr);
412388
}
413389

414-
TEST_P(D2ZZ2D2D, ForwardReference) {
415-
GTEST_SKIP() << "D2Z/Z2D 2D not yet supported";
390+
TEST(Real2D, Z2DPlanNotSupported) {
391+
flagfftHandle plan = nullptr;
392+
EXPECT_EQ(flagfftPlan2d(&plan, 64, 32, FLAGFFT_Z2D), FLAGFFT_NOT_SUPPORTED);
393+
EXPECT_EQ(plan, nullptr);
416394
}
417395

418-
INSTANTIATE_TEST_SUITE_P(Smoke, D2ZZ2D2D, ::testing::Values(Test2DParam {16, 16, 1}));
396+
TEST(Real2D, R2CPlanManyNotSupported) {
397+
flagfftHandle plan = nullptr;
398+
int n[2] = {64, 32};
399+
EXPECT_EQ(flagfftPlanMany(&plan, 2, n, nullptr, 1, 64 * 32, nullptr, 1, 64 * 17, FLAGFFT_R2C, 1),
400+
FLAGFFT_NOT_SUPPORTED);
401+
EXPECT_EQ(plan, nullptr);
402+
}
419403

420-
INSTANTIATE_TEST_SUITE_P(Extended,
421-
D2ZZ2D2D,
422-
::testing::ValuesIn(Generate2DParams(k2DSizes, k2DNumSizes, k2DBatchSingle, 1)));
404+
TEST(Real2D, D2ZPlanManyNotSupported) {
405+
flagfftHandle plan = nullptr;
406+
int n[2] = {64, 32};
407+
EXPECT_EQ(flagfftPlanMany(&plan, 2, n, nullptr, 1, 64 * 32, nullptr, 1, 64 * 17, FLAGFFT_D2Z, 1),
408+
FLAGFFT_NOT_SUPPORTED);
409+
EXPECT_EQ(plan, nullptr);
410+
}
423411

424412
} // namespace

src/adaptor/backend/cuda/test_adaptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static cufftType to_cufft_type(flagfftType type) {
8080

8181
static void check_cufft(cufftResult r, const std::string& context) {
8282
if (r != CUFFT_SUCCESS) {
83-
std::fprintf(stderr, "%s failed with code %d\n", context.c_str(), static_cast<int>(r));
83+
throw std::runtime_error(context + " failed with code " + std::to_string(static_cast<int>(r)));
8484
}
8585
}
8686

tests/ctest/test_correctness.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
CTEST_TARGETS = [
66
"test_plan",
7+
"test_2d_correctness",
78
"test_exec_c2c_fwd_ct_s",
89
"test_exec_c2c_fwd_ct_b",
910
"test_exec_c2c_fwd_bs_s",

0 commit comments

Comments
 (0)