mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
12d093b459
This commit performs the changes necessary in order to integrate with revng-qa, the new project for cross-project quality assurance. Basically, the source code of all the tests has been moved in revng-qa, which will take care of producing "artifacts" (i.e., compiled programs), using the appropriate cross-compilers. revng will then consume them and produce new artifacts to be consumed by other tools down the pipeline. The directory structure of the tests has been reworked to reflect `revng-qa`. A large amount of boilerplate code has been dropped. Note that certain actions, that used to be carried out during testing, are now part of the regular build process. Specifically, lifting the tests is performed at build time, so that they can be installed.
67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
/// \file ConstantrangeSet.cpp
|
|
/// \brief Tests for ConstantrangeSet
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
// Boost includes
|
|
#define BOOST_TEST_MODULE ConstantrangeSet
|
|
bool init_unit_test();
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
// Local libraries includes
|
|
#include "revng/ADT/ConstantRangeSet.h"
|
|
|
|
BOOST_AUTO_TEST_CASE(TestEnumerate) {
|
|
using CRS = ConstantRangeSet;
|
|
|
|
auto Range = [](uint32_t Start, uint32_t End) {
|
|
return CRS({ { 32, Start }, { 32, End } });
|
|
};
|
|
|
|
llvm::ConstantRange ZeroFive({ 4, 0 }, { 4, 5 });
|
|
|
|
std::pair<CRS, std::vector<uint64_t>> Ranges[] = {
|
|
{ CRS(), {} },
|
|
{ CRS(4, true), { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } },
|
|
{ CRS(4, false), {} },
|
|
{ Range(10, 20), { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 } },
|
|
{ Range(10, 20).unionWith(Range(30, 40)),
|
|
{ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
|
30, 31, 32, 33, 34, 35, 36, 37, 38, 39 } },
|
|
{ CRS({ { 8, 250 }, { 8, 5 } }),
|
|
{ 0, 1, 2, 3, 4, 250, 251, 252, 253, 254, 255 } },
|
|
{ Range(10, 20).unionWith(Range(30, 40)).unionWith(Range(15, 35)),
|
|
{ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
|
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 } },
|
|
{ CRS(ZeroFive), { 0, 1, 2, 3, 4 } },
|
|
{ CRS(ZeroFive.inverse()), { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } },
|
|
{ CRS(ZeroFive.inverse()).intersectWith(CRS({ { 4, 10 }, { 4, 13 } })),
|
|
{ 10, 11, 12 } }
|
|
};
|
|
|
|
for (auto &P : Ranges) {
|
|
const ConstantRangeSet &Range = P.first;
|
|
const std::vector<uint64_t> &Expected = P.second;
|
|
|
|
Range.dump();
|
|
dbg << ": ";
|
|
|
|
unsigned I = 0;
|
|
auto It = Range.begin();
|
|
auto End = Range.end();
|
|
while (It != End) {
|
|
uint64_t Value = (*It).getLimitedValue();
|
|
revng_check(Value == Expected[I]);
|
|
dbg << " " << Value;
|
|
++It;
|
|
I++;
|
|
}
|
|
|
|
revng_check(I == Expected.size());
|
|
|
|
dbg << "\n";
|
|
}
|
|
}
|