From b8b846d3eb2c46f6b7532e47a6d84bb3502f237b Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 26 Jul 2022 22:54:27 -0700 Subject: [PATCH] [lib] add a testcase for csv read/write for io pin table --- .../libpcf/test/test_csv_io_pin_table.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libopenfpga/libpcf/test/test_csv_io_pin_table.cpp diff --git a/libopenfpga/libpcf/test/test_csv_io_pin_table.cpp b/libopenfpga/libpcf/test/test_csv_io_pin_table.cpp new file mode 100644 index 000000000..bc45ffe34 --- /dev/null +++ b/libopenfpga/libpcf/test/test_csv_io_pin_table.cpp @@ -0,0 +1,33 @@ +/******************************************************************** + * Unit test functions to validate the correctness of + * 1. parser of data structures + * 2. writer of data structures + *******************************************************************/ +/* Headers from vtrutils */ +#include "vtr_assert.h" +#include "vtr_log.h" + +/* Headers from fabric key */ +#include "read_csv_io_pin_table.h" +#include "write_csv_io_pin_table.h" + +int main(int argc, const char** argv) { + /* Ensure we have only one or two argument */ + VTR_ASSERT((2 == argc) || (3 == argc)); + + /* Parse the fabric key from an XML file */ + openfpga::IoPinTable io_pin_table = openfpga::read_csv_io_io_pin_table(argv[1]); + VTR_LOG("Read the I/O pin table from a csv file: %s.\n", + argv[1]); + + /* Output to an XML file + * This is optional only used when there is a second argument + */ + if (3 <= argc) { + write_csv_io_pin_table(std::string(argv[2]), io_pin_table); + VTR_LOG("Echo the I/O pin table to a csv file: %s.\n", + argv[2]); + } +} + +