From 1c5dab9d474d23abc3fb381bd1dd88d360582933 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Thu, 7 Feb 2019 13:13:03 -0800 Subject: [PATCH 01/14] [tests] Move existing tests/* into submodule nextpnr-tests --- .gitmodules | 3 ++ tests | 1 + tests/generic/main.cc | 28 ---------- tests/gui/quadtree.cc | 122 ------------------------------------------ tests/ice40/hx1k.cc | 106 ------------------------------------ tests/ice40/hx8k.cc | 106 ------------------------------------ tests/ice40/lp1k.cc | 106 ------------------------------------ tests/ice40/lp384.cc | 106 ------------------------------------ tests/ice40/lp8k.cc | 106 ------------------------------------ tests/ice40/main.cc | 27 ---------- tests/ice40/up5k.cc | 106 ------------------------------------ 11 files changed, 4 insertions(+), 813 deletions(-) create mode 100644 .gitmodules create mode 160000 tests delete mode 100644 tests/generic/main.cc delete mode 100644 tests/gui/quadtree.cc delete mode 100644 tests/ice40/hx1k.cc delete mode 100644 tests/ice40/hx8k.cc delete mode 100644 tests/ice40/lp1k.cc delete mode 100644 tests/ice40/lp384.cc delete mode 100644 tests/ice40/lp8k.cc delete mode 100644 tests/ice40/main.cc delete mode 100644 tests/ice40/up5k.cc diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..52194b76 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tests"] + path = tests + url = https://github.com/YosysHQ/nextpnr-tests diff --git a/tests b/tests new file mode 160000 index 00000000..031c11e3 --- /dev/null +++ b/tests @@ -0,0 +1 @@ +Subproject commit 031c11e393cc34da8c76f9fb5f97bf0921ac9380 diff --git a/tests/generic/main.cc b/tests/generic/main.cc deleted file mode 100644 index a2634711..00000000 --- a/tests/generic/main.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Miodrag Milanovic - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include "gtest/gtest.h" - -#include - -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/gui/quadtree.cc b/tests/gui/quadtree.cc deleted file mode 100644 index 6711e906..00000000 --- a/tests/gui/quadtree.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Serge Bazanski - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include "gtest/gtest.h" -#include "nextpnr.h" - -#include "quadtree.h" - -USING_NEXTPNR_NAMESPACE - -using QT = QuadTree; - -class QuadTreeTest : public ::testing::Test -{ - protected: - virtual void SetUp() { qt_ = new QT(QT::BoundingBox(0, 0, width_, height_)); } - virtual void TearDown() { delete qt_; } - - int width_ = 100; - int height_ = 100; - QT *qt_; -}; - -// Test that we're doing bound checking correctly. -TEST_F(QuadTreeTest, insert_bound_checking) -{ - ASSERT_TRUE(qt_->insert(QT::BoundingBox(10, 10, 20, 20), 10)); - ASSERT_TRUE(qt_->insert(QT::BoundingBox(0, 0, 100, 100), 10)); - ASSERT_FALSE(qt_->insert(QT::BoundingBox(10, 10, 101, 20), 10)); - ASSERT_FALSE(qt_->insert(QT::BoundingBox(-1, 10, 101, 20), 10)); - ASSERT_FALSE(qt_->insert(QT::BoundingBox(-1, -1, 20, 20), 10)); -} - -// Test whether we are not losing any elements. -TEST_F(QuadTreeTest, insert_count) -{ - auto rng = NEXTPNR_NAMESPACE::DeterministicRNG(); - - // Add 10000 random rectangles. - for (unsigned int i = 0; i < 10000; i++) { - int x0 = rng.rng(width_); - int y0 = rng.rng(height_); - int w = rng.rng(width_ - x0); - int h = rng.rng(width_ - y0); - int x1 = x0 + w; - int y1 = y0 + h; - ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i)); - ASSERT_EQ(qt_->size(), i + 1); - } - // Add 100000 random points. - for (unsigned int i = 0; i < 100000; i++) { - int x0 = rng.rng(width_); - int y0 = rng.rng(height_); - int x1 = x0; - int y1 = y0; - ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i)); - ASSERT_EQ(qt_->size(), i + 10001); - } -} - -// Test that we can insert and retrieve the same element. -TEST_F(QuadTreeTest, insert_retrieve_same) -{ - auto rng = NEXTPNR_NAMESPACE::DeterministicRNG(); - - // Add 10000 small random rectangles. - rng.rngseed(0); - for (int i = 0; i < 10000; i++) { - int x0 = rng.rng(width_); - int y0 = rng.rng(height_); - int w = rng.rng(width_ - x0); - int h = rng.rng(width_ - y0); - int x1 = x0 + w / 4; - int y1 = y0 + h / 4; - ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i)); - } - - // Restart RNG, make sure we get the same rectangles back. - rng.rngseed(0); - for (int i = 0; i < 10000; i++) { - int x0 = rng.rng(width_); - int y0 = rng.rng(height_); - int w = rng.rng(width_ - x0); - int h = rng.rng(width_ - y0); - int x1 = x0 + w / 4; - int y1 = y0 + h / 4; - - // try to find something in the middle of the square - int x = (x1 - x0) / 2 + x0; - int y = (y1 - y0) / 2 + y0; - - auto res = qt_->get(x, y); - // Somewhat arbirary test to make sure we don't return obscene - // amounts of data. - ASSERT_LT(res.size(), 200UL); - bool found = false; - for (auto elem : res) { - // Is this what we're looking for? - if (elem == i) { - found = true; - break; - } - } - ASSERT_TRUE(found); - } -} diff --git a/tests/ice40/hx1k.cc b/tests/ice40/hx1k.cc deleted file mode 100644 index 741c954b..00000000 --- a/tests/ice40/hx1k.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Clifford Wolf - * Copyright (C) 2018 Miodrag Milanovic - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include -#include "gtest/gtest.h" -#include "nextpnr.h" - -USING_NEXTPNR_NAMESPACE - -class HX1KTest : public ::testing::Test -{ - protected: - virtual void SetUp() - { - chipArgs.type = ArchArgs::HX1K; - chipArgs.package = "tq144"; - ctx = new Context(chipArgs); - } - - virtual void TearDown() { delete ctx; } - - ArchArgs chipArgs; - Context *ctx; -}; - -TEST_F(HX1KTest, bel_names) -{ - int bel_count = 0; - for (auto bel : ctx->getBels()) { - auto name = ctx->getBelName(bel); - ASSERT_EQ(bel, ctx->getBelByName(name)); - bel_count++; - } - ASSERT_EQ(bel_count, 1418); -} - -TEST_F(HX1KTest, wire_names) -{ - int wire_count = 0; - for (auto wire : ctx->getWires()) { - auto name = ctx->getWireName(wire); - assert(wire == ctx->getWireByName(name)); - wire_count++; - } - ASSERT_EQ(wire_count, 32802); -} - -TEST_F(HX1KTest, pip_names) -{ - int pip_count = 0; - for (auto pip : ctx->getPips()) { - auto name = ctx->getPipName(pip); - assert(pip == ctx->getPipByName(name)); - pip_count++; - } - ASSERT_EQ(pip_count, 345504); -} - -TEST_F(HX1KTest, uphill_to_downhill) -{ - for (auto dst : ctx->getWires()) { - for (auto uphill_pip : ctx->getPipsUphill(dst)) { - bool found_downhill = false; - for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_downhill); - found_downhill = true; - } - } - ASSERT_TRUE(found_downhill); - } - } -} - -TEST_F(HX1KTest, downhill_to_uphill) -{ - for (auto dst : ctx->getWires()) { - for (auto downhill_pip : ctx->getPipsDownhill(dst)) { - bool found_uphill = false; - for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_uphill); - found_uphill = true; - } - } - ASSERT_TRUE(found_uphill); - } - } -} diff --git a/tests/ice40/hx8k.cc b/tests/ice40/hx8k.cc deleted file mode 100644 index 517df0d6..00000000 --- a/tests/ice40/hx8k.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Clifford Wolf - * Copyright (C) 2018 Miodrag Milanovic - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include -#include "gtest/gtest.h" -#include "nextpnr.h" - -USING_NEXTPNR_NAMESPACE - -class HX8KTest : public ::testing::Test -{ - protected: - virtual void SetUp() - { - chipArgs.type = ArchArgs::HX8K; - chipArgs.package = "ct256"; - ctx = new Context(chipArgs); - } - - virtual void TearDown() { delete ctx; } - - ArchArgs chipArgs; - Context *ctx; -}; - -TEST_F(HX8KTest, bel_names) -{ - int bel_count = 0; - for (auto bel : ctx->getBels()) { - auto name = ctx->getBelName(bel); - ASSERT_EQ(bel, ctx->getBelByName(name)); - bel_count++; - } - ASSERT_EQ(bel_count, 7979); -} - -TEST_F(HX8KTest, wire_names) -{ - int wire_count = 0; - for (auto wire : ctx->getWires()) { - auto name = ctx->getWireName(wire); - assert(wire == ctx->getWireByName(name)); - wire_count++; - } - ASSERT_EQ(wire_count, 165894); -} - -TEST_F(HX8KTest, pip_names) -{ - int pip_count = 0; - for (auto pip : ctx->getPips()) { - auto name = ctx->getPipName(pip); - assert(pip == ctx->getPipByName(name)); - pip_count++; - } - ASSERT_EQ(pip_count, 1806080); -} - -TEST_F(HX8KTest, uphill_to_downhill) -{ - for (auto dst : ctx->getWires()) { - for (auto uphill_pip : ctx->getPipsUphill(dst)) { - bool found_downhill = false; - for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_downhill); - found_downhill = true; - } - } - ASSERT_TRUE(found_downhill); - } - } -} - -TEST_F(HX8KTest, downhill_to_uphill) -{ - for (auto dst : ctx->getWires()) { - for (auto downhill_pip : ctx->getPipsDownhill(dst)) { - bool found_uphill = false; - for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_uphill); - found_uphill = true; - } - } - ASSERT_TRUE(found_uphill); - } - } -} diff --git a/tests/ice40/lp1k.cc b/tests/ice40/lp1k.cc deleted file mode 100644 index 2fdba08b..00000000 --- a/tests/ice40/lp1k.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Clifford Wolf - * Copyright (C) 2018 Miodrag Milanovic - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include -#include "gtest/gtest.h" -#include "nextpnr.h" - -USING_NEXTPNR_NAMESPACE - -class LP1KTest : public ::testing::Test -{ - protected: - virtual void SetUp() - { - chipArgs.type = ArchArgs::LP1K; - chipArgs.package = "tq144"; - ctx = new Context(chipArgs); - } - - virtual void TearDown() { delete ctx; } - - ArchArgs chipArgs; - Context *ctx; -}; - -TEST_F(LP1KTest, bel_names) -{ - int bel_count = 0; - for (auto bel : ctx->getBels()) { - auto name = ctx->getBelName(bel); - ASSERT_EQ(bel, ctx->getBelByName(name)); - bel_count++; - } - ASSERT_EQ(bel_count, 1418); -} - -TEST_F(LP1KTest, wire_names) -{ - int wire_count = 0; - for (auto wire : ctx->getWires()) { - auto name = ctx->getWireName(wire); - assert(wire == ctx->getWireByName(name)); - wire_count++; - } - ASSERT_EQ(wire_count, 32802); -} - -TEST_F(LP1KTest, pip_names) -{ - int pip_count = 0; - for (auto pip : ctx->getPips()) { - auto name = ctx->getPipName(pip); - assert(pip == ctx->getPipByName(name)); - pip_count++; - } - ASSERT_EQ(pip_count, 345504); -} - -TEST_F(LP1KTest, uphill_to_downhill) -{ - for (auto dst : ctx->getWires()) { - for (auto uphill_pip : ctx->getPipsUphill(dst)) { - bool found_downhill = false; - for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_downhill); - found_downhill = true; - } - } - ASSERT_TRUE(found_downhill); - } - } -} - -TEST_F(LP1KTest, downhill_to_uphill) -{ - for (auto dst : ctx->getWires()) { - for (auto downhill_pip : ctx->getPipsDownhill(dst)) { - bool found_uphill = false; - for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_uphill); - found_uphill = true; - } - } - ASSERT_TRUE(found_uphill); - } - } -} diff --git a/tests/ice40/lp384.cc b/tests/ice40/lp384.cc deleted file mode 100644 index a030b77b..00000000 --- a/tests/ice40/lp384.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Clifford Wolf - * Copyright (C) 2018 Miodrag Milanovic - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include -#include "gtest/gtest.h" -#include "nextpnr.h" - -USING_NEXTPNR_NAMESPACE - -class LP384Test : public ::testing::Test -{ - protected: - virtual void SetUp() - { - chipArgs.type = ArchArgs::LP384; - chipArgs.package = "qn32"; - ctx = new Context(chipArgs); - } - - virtual void TearDown() { delete ctx; } - - ArchArgs chipArgs; - Context *ctx; -}; - -TEST_F(LP384Test, bel_names) -{ - int bel_count = 0; - for (auto bel : ctx->getBels()) { - auto name = ctx->getBelName(bel); - ASSERT_EQ(bel, ctx->getBelByName(name)); - bel_count++; - } - ASSERT_EQ(bel_count, 449); -} - -TEST_F(LP384Test, wire_names) -{ - int wire_count = 0; - for (auto wire : ctx->getWires()) { - auto name = ctx->getWireName(wire); - assert(wire == ctx->getWireByName(name)); - wire_count++; - } - ASSERT_EQ(wire_count, 9830); -} - -TEST_F(LP384Test, pip_names) -{ - int pip_count = 0; - for (auto pip : ctx->getPips()) { - auto name = ctx->getPipName(pip); - assert(pip == ctx->getPipByName(name)); - pip_count++; - } - ASSERT_EQ(pip_count, 94544); -} - -TEST_F(LP384Test, uphill_to_downhill) -{ - for (auto dst : ctx->getWires()) { - for (auto uphill_pip : ctx->getPipsUphill(dst)) { - bool found_downhill = false; - for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_downhill); - found_downhill = true; - } - } - ASSERT_TRUE(found_downhill); - } - } -} - -TEST_F(LP384Test, downhill_to_uphill) -{ - for (auto dst : ctx->getWires()) { - for (auto downhill_pip : ctx->getPipsDownhill(dst)) { - bool found_uphill = false; - for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_uphill); - found_uphill = true; - } - } - ASSERT_TRUE(found_uphill); - } - } -} diff --git a/tests/ice40/lp8k.cc b/tests/ice40/lp8k.cc deleted file mode 100644 index 7fe6ac37..00000000 --- a/tests/ice40/lp8k.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Clifford Wolf - * Copyright (C) 2018 Miodrag Milanovic - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include -#include "gtest/gtest.h" -#include "nextpnr.h" - -USING_NEXTPNR_NAMESPACE - -class LP8KTest : public ::testing::Test -{ - protected: - virtual void SetUp() - { - chipArgs.type = ArchArgs::LP8K; - chipArgs.package = "ct256"; - ctx = new Context(chipArgs); - } - - virtual void TearDown() { delete ctx; } - - ArchArgs chipArgs; - Context *ctx; -}; - -TEST_F(LP8KTest, bel_names) -{ - int bel_count = 0; - for (auto bel : ctx->getBels()) { - auto name = ctx->getBelName(bel); - ASSERT_EQ(bel, ctx->getBelByName(name)); - bel_count++; - } - ASSERT_EQ(bel_count, 7979); -} - -TEST_F(LP8KTest, wire_names) -{ - int wire_count = 0; - for (auto wire : ctx->getWires()) { - auto name = ctx->getWireName(wire); - assert(wire == ctx->getWireByName(name)); - wire_count++; - } - ASSERT_EQ(wire_count, 165894); -} - -TEST_F(LP8KTest, pip_names) -{ - int pip_count = 0; - for (auto pip : ctx->getPips()) { - auto name = ctx->getPipName(pip); - assert(pip == ctx->getPipByName(name)); - pip_count++; - } - ASSERT_EQ(pip_count, 1806080); -} - -TEST_F(LP8KTest, uphill_to_downhill) -{ - for (auto dst : ctx->getWires()) { - for (auto uphill_pip : ctx->getPipsUphill(dst)) { - bool found_downhill = false; - for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_downhill); - found_downhill = true; - } - } - ASSERT_TRUE(found_downhill); - } - } -} - -TEST_F(LP8KTest, downhill_to_uphill) -{ - for (auto dst : ctx->getWires()) { - for (auto downhill_pip : ctx->getPipsDownhill(dst)) { - bool found_uphill = false; - for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_uphill); - found_uphill = true; - } - } - ASSERT_TRUE(found_uphill); - } - } -} diff --git a/tests/ice40/main.cc b/tests/ice40/main.cc deleted file mode 100644 index 60b9fdaa..00000000 --- a/tests/ice40/main.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Miodrag Milanovic - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include -#include "gtest/gtest.h" - -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/ice40/up5k.cc b/tests/ice40/up5k.cc deleted file mode 100644 index 582876e8..00000000 --- a/tests/ice40/up5k.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Clifford Wolf - * Copyright (C) 2018 Miodrag Milanovic - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include -#include "gtest/gtest.h" -#include "nextpnr.h" - -USING_NEXTPNR_NAMESPACE - -class UP5KTest : public ::testing::Test -{ - protected: - virtual void SetUp() - { - chipArgs.type = ArchArgs::UP5K; - chipArgs.package = "sg48"; - ctx = new Context(chipArgs); - } - - virtual void TearDown() { delete ctx; } - - ArchArgs chipArgs; - Context *ctx; -}; - -TEST_F(UP5KTest, bel_names) -{ - int bel_count = 0; - for (auto bel : ctx->getBels()) { - auto name = ctx->getBelName(bel); - ASSERT_EQ(bel, ctx->getBelByName(name)); - bel_count++; - } - ASSERT_EQ(bel_count, 5438); -} - -TEST_F(UP5KTest, wire_names) -{ - int wire_count = 0; - for (auto wire : ctx->getWires()) { - auto name = ctx->getWireName(wire); - assert(wire == ctx->getWireByName(name)); - wire_count++; - } - ASSERT_EQ(wire_count, 124503); -} - -TEST_F(UP5KTest, pip_names) -{ - int pip_count = 0; - for (auto pip : ctx->getPips()) { - auto name = ctx->getPipName(pip); - assert(pip == ctx->getPipByName(name)); - pip_count++; - } - ASSERT_EQ(pip_count, 1324704); -} - -TEST_F(UP5KTest, uphill_to_downhill) -{ - for (auto dst : ctx->getWires()) { - for (auto uphill_pip : ctx->getPipsUphill(dst)) { - bool found_downhill = false; - for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_downhill); - found_downhill = true; - } - } - ASSERT_TRUE(found_downhill); - } - } -} - -TEST_F(UP5KTest, downhill_to_uphill) -{ - for (auto dst : ctx->getWires()) { - for (auto downhill_pip : ctx->getPipsDownhill(dst)) { - bool found_uphill = false; - for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) { - if (uphill_pip == downhill_pip) { - ASSERT_FALSE(found_uphill); - found_uphill = true; - } - } - ASSERT_TRUE(found_uphill); - } - } -} From 09207cf91ffe586ca3d1df3a965035c60b5b5fa0 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Thu, 7 Feb 2019 13:21:03 -0800 Subject: [PATCH 02/14] [test] Update submodule pointer --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index 031c11e3..7bc3b6c7 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 031c11e393cc34da8c76f9fb5f97bf0921ac9380 +Subproject commit 7bc3b6c7589354e490321e8281bfe952fdd6fb55 From f3f404e81cb145ad0d1927966eb5539a127ec34a Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Thu, 7 Feb 2019 14:23:58 -0800 Subject: [PATCH 03/14] [tests] Update submodule --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index 7bc3b6c7..54d75e8c 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 7bc3b6c7589354e490321e8281bfe952fdd6fb55 +Subproject commit 54d75e8cfec1957778f159876047dbdc476fac84 From 0639be79667da425b8f86a401af1fad5c99e1bc7 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Fri, 8 Feb 2019 07:02:07 -0800 Subject: [PATCH 04/14] [tests] Update submodule --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index 54d75e8c..bbe819a2 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 54d75e8cfec1957778f159876047dbdc476fac84 +Subproject commit bbe819a2ea2ddb12c1575ebb075008e19da402b2 From 366151ad61aba6a6285e99cbc59b54249a979162 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Sat, 9 Feb 2019 10:31:37 -0800 Subject: [PATCH 05/14] [tests] Update submodule --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index bbe819a2..491b895f 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit bbe819a2ea2ddb12c1575ebb075008e19da402b2 +Subproject commit 491b895f954120c2c532ed1e310ec85b5fbf0d2a From 9238f1cfd73a276ac0f8d5410fc5159bdd202db1 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Sat, 9 Feb 2019 11:31:04 -0800 Subject: [PATCH 06/14] [tests] Update submodule --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index 491b895f..78c05ae3 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 491b895f954120c2c532ed1e310ec85b5fbf0d2a +Subproject commit 78c05ae3500904340d5e6a6ac3a74ae8bcaa1ca5 From fcb6362279a2f0b06d7cd07ce8fe9247de39ea48 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Sat, 9 Feb 2019 11:35:46 -0800 Subject: [PATCH 07/14] [tests] Update submodule --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index 78c05ae3..a0b9fdad 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 78c05ae3500904340d5e6a6ac3a74ae8bcaa1ca5 +Subproject commit a0b9fdade80b92b5fc8f44aa1c225dc8ac983e37 From 4ac505701ed97dfa601ae33e0330a81bc034fc29 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Sat, 9 Feb 2019 12:08:06 -0800 Subject: [PATCH 08/14] [tests] Add to CI --- .cirrus.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 38e14513..d7aa01e0 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,4 +9,5 @@ task: test_generic_script: cd build && ./nextpnr-generic-test test_ice40_script: cd build && ./nextpnr-ice40-test smoketest_ice40_script: export NEXTPNR=$(pwd)/build/nextpnr-ice40 && cd ice40/smoketest/attosoc && ./smoketest.sh - test_ecp5_script: cd build && ./nextpnr-ecp5-test \ No newline at end of file + test_ecp5_script: cd build && ./nextpnr-ecp5-test + regressions_ice40: make -C tests/ice40/regressions From ef8105bfbada1e5e7c875bf230479fbfddcaecc4 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Mon, 11 Feb 2019 08:42:13 -0800 Subject: [PATCH 09/14] [tests] Retry .cirrus.yml --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index d7aa01e0..6860b994 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -10,4 +10,4 @@ task: test_ice40_script: cd build && ./nextpnr-ice40-test smoketest_ice40_script: export NEXTPNR=$(pwd)/build/nextpnr-ice40 && cd ice40/smoketest/attosoc && ./smoketest.sh test_ecp5_script: cd build && ./nextpnr-ecp5-test - regressions_ice40: make -C tests/ice40/regressions + regressions_ice40_script: make -C tests/ice40/regressions NPNR=$(pwd)/build/nextpnr-ice40 From b35090d77cb60aa8f3abdb4dd4c7572b9d1f226b Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Mon, 11 Feb 2019 08:51:25 -0800 Subject: [PATCH 10/14] [timing] Do I need test in the task name too? --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 6860b994..177cda13 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -10,4 +10,4 @@ task: test_ice40_script: cd build && ./nextpnr-ice40-test smoketest_ice40_script: export NEXTPNR=$(pwd)/build/nextpnr-ice40 && cd ice40/smoketest/attosoc && ./smoketest.sh test_ecp5_script: cd build && ./nextpnr-ecp5-test - regressions_ice40_script: make -C tests/ice40/regressions NPNR=$(pwd)/build/nextpnr-ice40 + regressiontest_ice40_script: make -C tests/ice40/regressions NPNR=$(pwd)/build/nextpnr-ice40 From 6d2594d95b785a0be4847c110184ca05dbc10e44 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Mon, 11 Feb 2019 09:32:27 -0800 Subject: [PATCH 11/14] [tests] Do git submodule sync/update --- .cirrus.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cirrus.yml b/.cirrus.yml index 177cda13..465676d8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -6,6 +6,7 @@ task: dockerfile: .cirrus/Dockerfile.ubuntu16.04 build_script: mkdir build && cd build && cmake .. -DARCH=all -DTRELLIS_ROOT=/usr/local/src/prjtrellis -DBUILD_TESTS=on && make -j $(nproc) + submodule_script: git submodule sync --recursive && git submodule update --init --recursive test_generic_script: cd build && ./nextpnr-generic-test test_ice40_script: cd build && ./nextpnr-ice40-test smoketest_ice40_script: export NEXTPNR=$(pwd)/build/nextpnr-ice40 && cd ice40/smoketest/attosoc && ./smoketest.sh From 6fed51ee3d1c892a18d090a6c108d867d7d6a55b Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Mon, 11 Feb 2019 10:17:56 -0800 Subject: [PATCH 12/14] [tests] Run ice40 regressions in parallel --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 465676d8..2347b502 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -11,4 +11,4 @@ task: test_ice40_script: cd build && ./nextpnr-ice40-test smoketest_ice40_script: export NEXTPNR=$(pwd)/build/nextpnr-ice40 && cd ice40/smoketest/attosoc && ./smoketest.sh test_ecp5_script: cd build && ./nextpnr-ecp5-test - regressiontest_ice40_script: make -C tests/ice40/regressions NPNR=$(pwd)/build/nextpnr-ice40 + regressiontest_ice40_script: make -j $(nproc) -C tests/ice40/regressions NPNR=$(pwd)/build/nextpnr-ice40 From e9e9b9469c822c7a3a932383e66da8d6e59cae70 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 12 Feb 2019 17:02:38 -0800 Subject: [PATCH 13/14] [tests] Update submodule --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index a0b9fdad..7678a590 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit a0b9fdade80b92b5fc8f44aa1c225dc8ac983e37 +Subproject commit 7678a5904b06d8eb23165058a1b0a753ae0ed02e From e649b1e4ed0d770ee04671f979c03a2f7d047799 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 12 Feb 2019 21:27:12 -0800 Subject: [PATCH 14/14] [tests] Update submodule --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index 7678a590..691dfb82 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 7678a5904b06d8eb23165058a1b0a753ae0ed02e +Subproject commit 691dfb8204131bec7f1c5e139764bf418640f941