Commit 4ce73b99 authored by Yann Garcia's avatar Yann Garcia
Browse files

Add Upper Tester for UERANSIM

parent d62de8ed
Loading
Loading
Loading
Loading
+16.5 KiB

File added.

No diff preview for this file type.

+1.24 KiB

File added.

No diff preview for this file type.

+1.75 KiB

File added.

No diff preview for this file type.

+2.09 KiB

File added.

No diff preview for this file type.

+76 −0
Original line number Diff line number Diff line
#include <iostream>
#include <vector>
#include <string>

#include "async_process.hh"

#include "NGAP_Steps.hh"

#include "loggers.hh"

static async_process gnb_proc;
static async_process ue_proc;

namespace NGAP__Steps {

  INTEGER fx__ut__start__gnb(const CHARSTRING& p__binary__file, const CHARSTRING& p__config__file) {
    loggers::get_instance().log_msg(">>> fx__ut__start__gnb: p__binary__file: ", p__binary__file);
    loggers::get_instance().log_msg(">>> fx__ut__start__gnb: 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__gnb: p__config__file: '%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());
        std::cout << "GNB STDOUT: " << chunk;
      }
    }};
    try {
      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;
    }

    return 0;
  }

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

INTEGER fx__ut__start__ue(const CHARSTRING& p__binary__file, const CHARSTRING& p__config__file) {
  loggers::get_instance().log_msg(">>> fx__ut__start__ue: p__binary__file: ", p__binary__file);
  loggers::get_instance().log_msg(">>> fx__ut__start__ue: 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__ue: '%s'", std::string(chunk).c_str());
        std::cerr << "UE STDERR: " << chunk;
      } else {
        loggers::get_instance().log("fx__ut__start__ue: '%s'", std::string(chunk).c_str());
        std::cout << "UE STDOUT: " << chunk;
      }
  }};
  try {
    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;
  }

  return 0;
}

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

} // End of namespace NGAP__Steps
Loading