From 23e3d37b3dbfd64a845e481777f780d08a967f68 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Wed, 27 Jul 2022 11:24:05 -0700 Subject: [PATCH] [lib] add test for pcf reader/writer --- libopenfpga/libpcf/test/test_pcf.cpp | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 libopenfpga/libpcf/test/test_pcf.cpp diff --git a/libopenfpga/libpcf/test/test_pcf.cpp b/libopenfpga/libpcf/test/test_pcf.cpp new file mode 100644 index 000000000..fa71799ac --- /dev/null +++ b/libopenfpga/libpcf/test/test_pcf.cpp @@ -0,0 +1,34 @@ +/******************************************************************** + * 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 "pcf_reader.h" +#include "pcf_writer.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::PcfData pcf_data; + openfpga::read_pcf(argv[1], pcf_data); + VTR_LOG("Read the design constraints from a pcf 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_pcf(argv[2], pcf_data); + VTR_LOG("Echo the design constraints to a pcf file: %s.\n", + argv[2]); + } +} + +