fix location of support/ folder. Created macros for ASSERT_EQ and ASSERT_NEQ

master
Francisco Paisana 3 years ago
parent 599fc978a5
commit f518861ebc

@ -14,7 +14,7 @@
#define SRSRAN_DYN_BITSET_H
#include "srsran/srslog/bundled/fmt/format.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <cstdint>
#include <inttypes.h>
#include <string>

@ -14,7 +14,7 @@
#define SRSRAN_BOUNDED_VECTOR_H
#include "srsran/adt/detail/type_storage.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <iterator>
#include <memory>
#include <type_traits>

@ -16,7 +16,7 @@
#include "srsran/adt/detail/type_storage.h"
#include "srsran/adt/expected.h"
#include "srsran/adt/pool/pool_utils.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <array>
#include <cassert>

@ -15,7 +15,7 @@
#include "detail/type_storage.h"
#include "expected.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <array>
namespace srsran {

@ -13,7 +13,7 @@
#ifndef SRSRAN_EXPECTED_H
#define SRSRAN_EXPECTED_H
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <memory>
#include <system_error>

@ -14,7 +14,7 @@
#define SRSRAN_INTERVAL_H
#include "srsran/srslog/bundled/fmt/format.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <cassert>
#include <string>
#include <type_traits>

@ -14,7 +14,7 @@
#define SRSRAN_MOVE_CALLBACK_H
#include "detail/type_storage.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <cstddef>
#include <cstdint>
#include <cstdio>

@ -14,7 +14,7 @@
#define SRSRAN_OPTIONAL_H
#include "detail/type_storage.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
namespace srsran {

@ -16,7 +16,7 @@
#include "memblock_cache.h"
#include "pool_utils.h"
#include "srsran/common/thread_pool.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <memory>
#include <mutex>

@ -14,7 +14,7 @@
#define SRSRAN_LINEAR_ALLOCATOR_H
#include "pool_utils.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
namespace srsran {

@ -14,7 +14,7 @@
#define SRSASN_COMMON_UTILS_H
#include "srsran/srslog/srslog.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <algorithm>
#include <array>
#include <cmath>

@ -14,7 +14,7 @@
#define SRSRAN_SLOT_POINT_H
#include "srsran/adt/interval.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
namespace srsran {

@ -14,6 +14,7 @@
#define SRSRAN_TEST_COMMON_H
#include "srsran/config.h"
#include "srsran/support/srsran_test.h"
#ifdef __cplusplus
@ -21,7 +22,6 @@
#include "srsran/common/crash_handler.h"
#include "srsran/common/standard_streams.h"
#include "srsran/srslog/srslog.h"
#include "support/srsran_assert.h"
#include <atomic>
#include <cstdio>
@ -159,20 +159,6 @@ inline void copy_msg_to_buffer(unique_byte_buffer_t& pdu, const_byte_span msg)
#define TESTERROR(fmt, ...) CONDERROR(true, fmt, ##__VA_ARGS__)
#define TESTASSERT(cond) srsran_assert((cond), "Fail at \"%s\"", (#cond))
#else // if C
#include <stdio.h>
#define TESTASSERT(cond) \
do { \
if (!(cond)) { \
printf("[%s][Line %d] Fail at \"%s\"\n", __FUNCTION__, __LINE__, (#cond)); \
return -1; \
} \
} while (0)
#endif // __cplusplus
#endif // SRSRAN_TEST_COMMON_H

@ -16,7 +16,7 @@
#include "srsran/adt/interval.h"
#include "srsran/common/common.h"
#include "srsran/srslog/srslog.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <cstdint>
#include <limits>

@ -24,8 +24,8 @@
#include "srsran/interfaces/pdcp_interface_types.h"
#include "srsran/rlc/rlc_am_base.h"
#include "srsran/rlc/rlc_common.h"
#include "srsran/support/srsran_assert.h"
#include "srsran/upper/byte_buffer_queue.h"
#include "support/srsran_assert.h"
#include <deque>
#include <list>
#include <map>

@ -0,0 +1,64 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#ifndef SRSRAN_SRSRAN_TEST_H
#define SRSRAN_SRSRAN_TEST_H
#ifdef __cplusplus
#include "srsran_assert.h"
namespace srsran {
namespace detail {
template <typename T, typename U>
[[gnu::noinline, noreturn]] void assert_eq_failure(const T& expected_val, const U& actual_val)
{
std::string s = fmt::format("Actual value '{}' differs from expected '{}'", actual_val, expected_val);
srsran_assertion_failure("%s", s.c_str());
}
template <typename T>
[[gnu::noinline, noreturn]] void assert_neq_failure(const T& actual_val)
{
std::string s = fmt::format("Value should not be equal to '{}'", actual_val);
srsran_assertion_failure("%s", s.c_str());
}
} // namespace detail
} // namespace srsran
#define TESTASSERT_EQ(EXPECTED, ACTUAL) \
(void)((EXPECTED == ACTUAL) || (::srsran::detail::assert_eq_failure(EXPECTED, ACTUAL), 0))
#define TESTASSERT_NEQ(EXPECTED, ACTUAL) \
(void)((EXPECTED != ACTUAL) || (::srsran::detail::assert_neq_failure(ACTUAL), 0))
#define TESTASSERT(cond) srsran_assert((cond), "Fail at \"%s\"", (#cond))
#define TESTASSERT_SUCCESS(cond) srsran_assert((cond == SRSRAN_SUCCESS), "Operation \"%s\" was not successful", (#cond))
#else // __cplusplus
#include <stdio.h>
#define TESTASSERT(cond) \
do { \
if (!(cond)) { \
printf("[%s][Line %d] Fail at \"%s\"\n", __FUNCTION__, __LINE__, (#cond)); \
return -1; \
} \
} while (0)
#endif // __cplusplus
#endif // SRSRAN_SRSRAN_TEST_H

@ -10,8 +10,8 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/srsran.h"
#include "srsran/support/srsran_test.h"
#include <complex.h>
#include <stdio.h>
#include <stdlib.h>

@ -10,8 +10,8 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/phy/ch_estimation/csi_rs.h"
#include "srsran/support/srsran_test.h"
static srsran_carrier_nr_t carrier = {};

@ -10,9 +10,9 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/phy/ch_estimation/csi_rs.h"
#include "srsran/phy/utils/vector.h"
#include "srsran/support/srsran_test.h"
#include <getopt.h>
#include <srsran/srsran.h>
#include <stdlib.h>

@ -10,9 +10,9 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/phy/ch_estimation/dmrs_pdcch.h"
#include "srsran/phy/phch/pdcch_nr.h"
#include "srsran/support/srsran_test.h"
#include <complex.h>
#include <stdio.h>
#include <stdlib.h>

@ -10,10 +10,10 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/phy/ch_estimation/dmrs_sch.h"
#include "srsran/phy/phch/ra_dl_nr.h"
#include "srsran/srsran.h"
#include "srsran/support/srsran_test.h"
#include <complex.h>
#include <stdio.h>
#include <stdlib.h>

@ -9,10 +9,10 @@
* the distribution.
*
*/
#include "srsran/common/test_common.h"
#include "srsran/phy/fec/block/block.h"
#include "srsran/phy/utils/debug.h"
#include "srsran/phy/utils/random.h"
#include "srsran/support/srsran_test.h"
#include <memory.h>
#include <srsran/phy/utils/vector.h>
#include <stdio.h>

@ -11,8 +11,8 @@
*/
#include "polar_interleaver_gold.h"
#include "srsran/common/test_common.h"
#include "srsran/phy/fec/polar/polar_interleaver.h"
#include "srsran/support/srsran_test.h"
int main(int argc, char** argv)
{

@ -10,10 +10,10 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/phy/phch/dci_nr.h"
#include "srsran/phy/utils/debug.h"
#include "srsran/phy/utils/random.h"
#include "srsran/support/srsran_test.h"
#include <getopt.h>
static uint32_t nof_repetitions = 1024;

@ -10,8 +10,8 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/phy/utils/re_pattern.h"
#include "srsran/support/srsran_test.h"
int main(int argc, char** argv)
{

@ -10,7 +10,7 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/support/srsran_test.h"
#include <complex.h>
#include <math.h>
#include <pthread.h>

@ -11,7 +11,7 @@
*/
#include "srsran/adt/bounded_vector.h"
#include "srsran/common/test_common.h"
#include "srsran/support/srsran_test.h"
namespace srsran {
@ -52,7 +52,7 @@ struct moveonly {
moveonly& operator=(moveonly&&) noexcept = default;
};
int test_ctor()
void test_ctor()
{
// TEST: default ctor
bounded_vector<int, 10> a;
@ -88,11 +88,9 @@ int test_ctor()
bounded_vector<int, 20> a6(std::move(a5));
TESTASSERT(a6.size() == 7);
TESTASSERT(a5.size() == 0);
return SRSRAN_SUCCESS;
}
int test_obj_add_rem()
void test_obj_add_rem()
{
// TEST: push_back / emplace_back
bounded_vector<C, 10> a;
@ -154,11 +152,9 @@ int test_obj_add_rem()
a2.clear();
a = std::move(a2);
TESTASSERT(a.empty() and a2.empty());
return SRSRAN_SUCCESS;
}
int test_move_only_type()
void test_move_only_type()
{
bounded_vector<moveonly, 10> a(5);
TESTASSERT(a.size() == 5);
@ -175,24 +171,21 @@ int test_move_only_type()
a2.push_back(moveonly());
TESTASSERT(a2.size() == 7);
return SRSRAN_SUCCESS;
}
int assert_dtor_consistency()
void assert_dtor_consistency()
{
TESTASSERT(C::nof_dtor == C::nof_copy_ctor + C::nof_value_ctor + C::nof_move_ctor);
return SRSRAN_SUCCESS;
}
} // namespace srsran
int main()
{
TESTASSERT(srsran::test_ctor() == SRSRAN_SUCCESS);
TESTASSERT(srsran::test_obj_add_rem() == SRSRAN_SUCCESS);
TESTASSERT(srsran::test_move_only_type() == SRSRAN_SUCCESS);
TESTASSERT(srsran::assert_dtor_consistency() == SRSRAN_SUCCESS);
srsran::test_ctor();
srsran::test_obj_add_rem();
srsran::test_move_only_type();
srsran::assert_dtor_consistency();
printf("Success\n");
return 0;
}

@ -10,8 +10,8 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/common/timers.h"
#include "srsran/support/srsran_test.h"
#include <iostream>
#include <random>
#include <srsran/common/tti_sync_cv.h>
@ -21,7 +21,7 @@ using namespace srsran;
static_assert(timer_handler::max_timer_duration() == 1073741823, "Invalid max duration");
int timers_test1()
void timers_test1()
{
timer_handler timers;
uint32_t dur = 5;
@ -110,8 +110,6 @@ int timers_test1()
}
// TEST: timer dtor is called and removes "timer" from "timers"
TESTASSERT(timers.nof_timers() == 0);
return SRSRAN_SUCCESS;
}
/**
@ -119,7 +117,7 @@ int timers_test1()
* - calling stop() early, forbids the timer from getting expired
* - calling stop() after timer has expired should be a noop
*/
int timers_test2()
void timers_test2()
{
timer_handler timers;
uint32_t duration = 2;
@ -145,15 +143,13 @@ int timers_test2()
// TEST 2: call utimer.stop() after it expires and assert it is still expired
utimer2.stop();
TESTASSERT(utimer2.is_expired());
return SRSRAN_SUCCESS;
}
/**
* Description:
* - setting a new duration while the timer is already running should not stop timer, and should extend timeout
*/
int timers_test3()
void timers_test3()
{
timer_handler timers;
uint32_t duration = 5;
@ -176,8 +172,6 @@ int timers_test3()
}
timers.step_all();
TESTASSERT(not utimer.is_running() and utimer.is_expired());
return SRSRAN_SUCCESS;
}
struct timers_test4_ctxt {
@ -218,7 +212,7 @@ static void timers2_test4_thread(timers_test4_ctxt* ctx)
}
}
int timers_test4()
void timers_test4()
{
timer_handler timers;
timers_test4_ctxt ctx;
@ -295,14 +289,12 @@ int timers_test4()
for (uint32_t i = 0; i < nof_timers; i++) {
TESTASSERT(not ctx.timers[i].is_running());
}
return SRSRAN_SUCCESS;
}
/**
* Description: Delaying a callback using the timer_handler
*/
int timers_test5()
void timers_test5()
{
timer_handler timers;
TESTASSERT(timers.nof_timers() == 0);
@ -354,14 +346,12 @@ int timers_test5()
TESTASSERT(timers.nof_timers() == 1);
TESTASSERT(vals.size() == 3);
TESTASSERT(vals[2] == 3);
return SRSRAN_SUCCESS;
}
/**
* Description: Check if erasure of a running timer is safe
*/
int timers_test6()
void timers_test6()
{
timer_handler timers;
@ -399,8 +389,6 @@ int timers_test6()
// TEST: The second timer's callback should be the one being called, and should be called only once
timers.step_all();
TESTASSERT(vals.size() == 1 and vals[0] == 3);
return SRSRAN_SUCCESS;
}
/**
@ -408,7 +396,7 @@ int timers_test6()
* - check if timer update is safe when its new updated wheel position matches the previous wheel position
* - multime timers can exist in the same wheel position
*/
int timers_test7()
void timers_test7()
{
timer_handler timers;
size_t wheel_size = timer_handler::get_wheel_size();
@ -449,19 +437,17 @@ int timers_test7()
TESTASSERT(not t2.is_expired() and t2.is_running());
TESTASSERT(t3.is_expired() and not t3.is_running());
TESTASSERT(timers.nof_running_timers() == 1 and timers.nof_timers() == 3);
return SRSRAN_SUCCESS;
}
int main()
{
TESTASSERT(timers_test1() == SRSRAN_SUCCESS);
TESTASSERT(timers_test2() == SRSRAN_SUCCESS);
TESTASSERT(timers_test3() == SRSRAN_SUCCESS);
TESTASSERT(timers_test4() == SRSRAN_SUCCESS);
TESTASSERT(timers_test5() == SRSRAN_SUCCESS);
TESTASSERT(timers_test6() == SRSRAN_SUCCESS);
TESTASSERT(timers_test7() == SRSRAN_SUCCESS);
timers_test1();
timers_test2();
timers_test3();
timers_test4();
timers_test5();
timers_test6();
timers_test7();
printf("Success\n");
return 0;
}

@ -11,12 +11,12 @@
*/
#include "srsran/common/slot_point.h"
#include "srsran/common/test_common.h"
#include "srsran/common/tti_point.h"
#include "srsran/support/srsran_test.h"
using srsran::tti_point;
int test_tti_type()
void test_tti_type()
{
// TEST: constructors
tti_point tti1;
@ -63,8 +63,6 @@ int test_tti_type()
TESTASSERT(tti_point{1u - 2u} == tti_point{10239});
TESTASSERT(tti_point{1u - 100u} == tti_point{10141});
TESTASSERT(tti_point{10239u + 3u} == tti_point{2});
return SRSRAN_SUCCESS;
}
void test_nr_slot_type()

@ -15,7 +15,7 @@
#include "srsran/adt/bounded_bitset.h"
#include "srsran/adt/interval.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
extern "C" {
#include "srsran/phy/phch/ra.h"
}

@ -22,7 +22,7 @@
#include "srsran/interfaces/enb_pdcp_interfaces.h"
#include "srsran/interfaces/enb_rlc_interfaces.h"
#include "srsran/interfaces/enb_s1ap_interfaces.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
using namespace asn1::rrc;

@ -17,7 +17,7 @@
#include "srsran/common/string_helpers.h"
#include "srsran/interfaces/enb_interfaces.h"
#include "srsran/interfaces/enb_pdcp_interfaces.h"
#include "support/srsran_assert.h"
#include "srsran/support/srsran_assert.h"
#include <errno.h>
#include <linux/ip.h>

@ -14,7 +14,7 @@
#include "srsenb/hdr/stack/mac/sched_lte_common.h"
#include "srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h"
#include "srsran/common/common_lte.h"
#include "srsran/common/test_common.h"
#include "srsran/support/srsran_test.h"
namespace srsenb {
@ -251,7 +251,7 @@ int test_min_mcs_tbs_specific()
CONDERROR(result.tbs_bytes * 8 != 120, "Invalid min TBS calculation");
args.req_bytes = 50;
TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSRAN_SUCCESS);
TESTASSERT_SUCCESS(test_min_mcs_tbs_dl_helper(cell_params, args, &result));
CONDERROR(result.tbs_bytes < (int)args.req_bytes, "Invalid MCS calculation");
CONDERROR(result.tbs_bytes * 8 != 424, "Invalid min TBS calculation");
@ -264,7 +264,7 @@ int test_min_mcs_tbs_specific()
// Check equality case
args.req_bytes = 109;
TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSRAN_SUCCESS);
TESTASSERT_SUCCESS(test_min_mcs_tbs_dl_helper(cell_params, args, &result));
CONDERROR(result.tbs_bytes < (int)args.req_bytes, "Invalid MCS calculation");
CONDERROR(result.tbs_bytes * 8 != 872, "Invalid min TBS calculation");
@ -294,18 +294,18 @@ void test_ul_mcs_tbs_derivation()
};
cqi = 0;
TESTASSERT(compute_tbs_mcs(25, 25 - 4).mcs == 0);
TESTASSERT(compute_tbs_mcs(50, 50 - 5).mcs == 0);
TESTASSERT_EQ(0, compute_tbs_mcs(25, 25 - 4).mcs);
TESTASSERT_EQ(0, compute_tbs_mcs(50, 50 - 5).mcs);
cqi = 5;
TESTASSERT(compute_tbs_mcs(25, 25 - 4).mcs == 9);
TESTASSERT(compute_tbs_mcs(50, 50 - 5).mcs == 9);
TESTASSERT_EQ(9, compute_tbs_mcs(25, 25 - 4).mcs);
TESTASSERT_EQ(9, compute_tbs_mcs(50, 50 - 5).mcs);
cqi = 15;
TESTASSERT(compute_tbs_mcs(25, 25 - 4).mcs == 23);
TESTASSERT(compute_tbs_mcs(50, 50 - 5).mcs == 23);
TESTASSERT(compute_tbs_mcs(75, 75 - 5).mcs == 24);
TESTASSERT(compute_tbs_mcs(100, 100 - 5).mcs == 23);
TESTASSERT_EQ(23, compute_tbs_mcs(25, 25 - 4).mcs);
TESTASSERT_EQ(23, compute_tbs_mcs(50, 50 - 5).mcs);
TESTASSERT_EQ(24, compute_tbs_mcs(75, 75 - 5).mcs);
TESTASSERT_EQ(23, compute_tbs_mcs(100, 100 - 5).mcs);
}
} // namespace srsenb

@ -13,8 +13,8 @@
#include "srsran/asn1/rrc/rr_common.h"
#include "srsran/asn1/rrc_utils.h"
#include "srsran/common/mac_pcap.h"
#include "srsran/common/test_common.h"
#include "srsran/common/tsan_options.h"
#include "srsran/support/srsran_test.h"
#include "srsran/test/ue_test_interfaces.h"
#include "srsue/hdr/stack/mac/mac.h"
#include "srsue/hdr/stack/mac/mux.h"

@ -11,10 +11,10 @@
*/
#include "srsran/common/bcd_helpers.h"
#include "srsran/common/test_common.h"
#include "srsran/common/tsan_options.h"
#include "srsran/interfaces/ue_pdcp_interfaces.h"
#include "srsran/srslog/srslog.h"
#include "srsran/support/srsran_test.h"
#include "srsran/test/ue_test_interfaces.h"
#include "srsue/hdr/stack/upper/gw.h"
#include "srsue/hdr/stack/upper/nas.h"

@ -10,7 +10,7 @@
*
*/
#include "srsran/common/test_common.h"
#include "srsran/support/srsran_test.h"
#include "srsue/hdr/stack/upper/usim.h"
using namespace srsue;

Loading…
Cancel
Save