Commit 0a297dc0 authored by Yann Garcia's avatar Yann Garcia
Browse files

Add Upper Tester for open5gs

parent fc6ca2df
Loading
Loading
Loading
Loading
(3.97 KiB)

File changed.

No diff preview for this file type.

+51 −5
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#include "loggers.hh"

static async_process open5gs_proc;
static async_process gnb_proc;
static async_process ue_proc;

@@ -19,16 +20,21 @@ namespace NGAP__Steps {

    async_process::Options opts = {false, "", [](std::string_view chunk, bool isStderr) {
      if (isStderr) {
        loggers::get_instance().warning("fx__ut__start__gnb: p__config__file: '%s'", std::string(chunk).c_str());
        loggers::get_instance().warning("fx__ut__start__gnb: '%s'", std::string(chunk).c_str());
        std::cerr << "GNB STDERR: " << chunk;
      } else {
        loggers::get_instance().log("fx__ut__start__gnb: p__config__file: '%s'", std::string(chunk).c_str());
        loggers::get_instance().log("fx__ut__start__gnb: '%s'", std::string(chunk).c_str());
        std::cout << "GNB STDOUT: " << chunk;
      }
    }};
    try {
      if (p__config__file.lengthof() == 0) {
        loggers::get_instance().log(">>> fx__ut__start__gnb: No config file provided, starting gNB without '-c' argument");
        gnb_proc.start(static_cast<const char*>(p__binary__file), {}, opts);
      } else {
        gnb_proc.start(static_cast<const char*>(p__binary__file), { "-c", static_cast<const char*>(p__config__file) }, opts);
      }
    }
    catch (const std::exception& e) {
      std::cerr << "fx__ut__start__gnb: Failed to start process: " << e.what() << std::endl;
      return -1;
@@ -57,8 +63,13 @@ INTEGER fx__ut__start__ue(const CHARSTRING& p__binary__file, const CHARSTRING& p
      }
  }};
  try {
      if (p__config__file.lengthof() == 0) {
        loggers::get_instance().log(">>> fx__ut__start__gnb: No config file provided, starting gNB without '-c' argument");
        ue_proc.start(static_cast<const char*>(p__binary__file), {}, opts);
      } else {
        ue_proc.start(static_cast<const char*>(p__binary__file), { "-c", static_cast<const char*>(p__config__file) }, opts);
      }
    }
  catch (const std::exception& e) {
    std::cerr << "fx__ut__start__gnb: Failed to start process: " << e.what() << std::endl;
    return -1;
@@ -73,4 +84,39 @@ INTEGER fx__ut__start__ue(const CHARSTRING& p__binary__file, const CHARSTRING& p
    return 0;
  }

  INTEGER fx__ut__start__open5gs(const CHARSTRING& p__binary__file, const CHARSTRING& p__config__file) {
    loggers::get_instance().log_msg(">>> fx__ut__start__open5gs: p__binary__file: ", p__binary__file);
    loggers::get_instance().log_msg(">>> fx__ut__start__open5gs: p__config__file: ", p__config__file);

    async_process::Options opts = {false, "", [](std::string_view chunk, bool isStderr) {
      if (isStderr) {
        loggers::get_instance().warning("fx__ut__start__open5gs: '%s'", std::string(chunk).c_str());
        std::cerr << "OPEN5GS STDERR: " << chunk;
      } else {
        loggers::get_instance().log("fx__ut__start__open5gs: '%s'", std::string(chunk).c_str());
        std::cout << "OPEN5GS STDOUT: " << chunk;
      }
    }};
    try {
      if (p__config__file.lengthof() == 0) {
        loggers::get_instance().log(">>> fx__ut__start__gnb: No config file provided, starting gNB without '-c' argument");
        open5gs_proc.start(static_cast<const char*>(p__binary__file), {}, opts);
      } else {
        open5gs_proc.start(static_cast<const char*>(p__binary__file), { "-c", static_cast<const char*>(p__config__file) }, opts);
      }
    }
    catch (const std::exception& e) {
      std::cerr << "fx__ut__start__open5gs: Failed to start process: " << e.what() << std::endl;
      return -1;
    }

    return 0;
  }

  INTEGER fx__ut__terminate__open5gs() {
    loggers::get_instance().log(">>> fx__ut__terminate__open5gs");
    open5gs_proc.terminate();
    return 0;
  }

} // End of namespace NGAP__Steps
+4 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ NGAP_Pics.PICS_NGAP_AMF_IUT := true
NGAP_Pics.PICS_NGAP_GNB_IUT    := false

LibNGAP_Pics.PICS_OFFLINE_MODE := false # true for offline mode with pcap files, false for online mode with SCTP server
LibNGAP_Pics.PICS_USE_OPEN5GS  := false # true to start UERANSIM gNB and UE simulators, false to not start them

LibNGAP_Pixits.PX_NAS_MCC          := '999'H
LibNGAP_Pixits.PX_NAS_MNC          := '70'H
@@ -55,6 +56,9 @@ Parameters.px_IMSI_Def := '39393937303030303030303
Parameters.px_IMEISV_Def                             := '73806121856151f1'H
NAS_5GC_Parameters.px_NAS_5GC_XRES_Length            := 8 # In ETSI TS 135 206 V16.0.0 (2020-08) Table Table 5. f2 output, RES length is 8 octets (64 bits)

# Upper tester parameters for UERANSIM integration
LibNGAP_Pixits.PX_OPEN5GS_BINARY_FILE := "/home/yann/dev/open5gs/build/tests/app/5gc"

[LOGGING]
# In this section you can specify the name of the log file and the classes of events
# you want to log into the file or display on console (standard error).
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ do
    fi
done

stty sane

exit 0

+5 −1
Original line number Diff line number Diff line
@@ -801,7 +801,7 @@ module NGAP_Steps { // TODO FSCOM f_xxx_UE_SecurityMode to be mmoved into NAG_NG

    }//end group BehaviorFunctions

    group ut_functions {
    group ut_functions { // TODO FSCOM To be enhanced with only one external function for starting and one for terminating the test system

        external function fx_ut_start_gnb(in charstring p_binary_file, in charstring p_config_file) return integer;

@@ -811,6 +811,10 @@ module NGAP_Steps { // TODO FSCOM f_xxx_UE_SecurityMode to be mmoved into NAG_NG

        external function fx_ut_terminate_ue() return integer;

        external function fx_ut_start_open5gs(in charstring p_binary_file, in charstring p_config_file) return integer;

        external function fx_ut_terminate_open5gs() return integer;

    } // End of group ut_functions

} // End of module NGAP_Steps
Loading