Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build UT #1

Open
omar-ocampo opened this issue Jun 7, 2018 · 0 comments
Open

How to build UT #1

omar-ocampo opened this issue Jun 7, 2018 · 0 comments

Comments

@omar-ocampo
Copy link

Hello,

I'm building openbmc using yocto, including phosphor-user-manager however I noticed the UT are not being built, here is an extract of the log for do_compile:

make[2]: Leaving directory '/home/foo/openbmc/build/tmp/work/corei7-64-openbmc-linux/phosphor-user-manager/1.0-r1/phosphor-user-manager-1.0'
Making all in test
make[2]: Entering directory '/home/foo/openbmc/build/tmp/work/corei7-64-openbmc-linux/phosphor-user-manager/1.0-r1/phosphor-user-manager-1.0/test'
make[2]: Nothing to be done for 'all'.

make[2]: Leaving directory '/home/foo/openbmc/build/tmp/work/corei7-64-openbmc-linux/phosphor-user-manager/1.0-r1/phosphor-user-manager-1.0/test'
make[1]: Leaving directory '/home/foo/openbmc/build/tmp/work/corei7-64-openbmc-linux/phosphor-user-manager/1.0-r1/phosphor-user-manager-1.0'

Here is my configure command:

NOTE: Running ../../../../../../workspace/sources/phosphor-user-manager/configure
--build=x86_64-linux
--host=x86_64-openbmc-linux
--target=x86_64-openbmc-linux
--prefix=/usr
--exec_prefix=/usr
--bindir=/usr/bin
--sbindir=/usr/sbin
--libexecdir=/usr/libexec
--datadir=/usr/share
--sysconfdir=/etc
--sharedstatedir=/com
--localstatedir=/var
--libdir=/usr/lib
--includedir=/usr/include
--oldincludedir=/usr/include
--infodir=/usr/share/info
--mandir=/usr/share/man
--disable-silent-rules
--disable-dependency-tracking
--with-libtool-sysroot=/home/foo/openbmc/build/tmp/work/corei7-64-openbmc-linux/phosphor-user-manager/1.0-r1/recipe-sysroot
--disable-static

Am I missing something required in the configure step to be able to build UTs?

dkodihal pushed a commit to NVIDIA/phosphor-user-manager that referenced this issue May 7, 2024
Changes added: Added code to handle value larger than compile time limit

Problem: Currently user not able set value larger than compile time value

Solution : Modified case to allow user to set set value larger than compile time value.

TEST :
curl -k -H X-Auth-Token: YuocwiA53jwAzwoj3cGT  -X GET https://127.0.0.1:2443/redfish/v1/AccountService
{
  "@odata.id": "/redfish/v1/AccountService",
  "@odata.type": "#AccountService.v1_5_0.AccountService",
  "AccountLockoutDuration": 600,
  "AccountLockoutThreshold": 3,
  "Accounts": {
    "@odata.id": "/redfish/v1/AccountService/Accounts"
  },
  "Description": "Account Service",
  "Id": "AccountService",
  "LDAP": {
    "Certificates": {
      "@odata.id": "/redfish/v1/AccountService/LDAP/Certificates"
    }
  },
  "MaxPasswordLength": 20,
  "MinPasswordLength": 13,
  "Name": "Account Service",
  "Oem": {
    "OpenBMC": {
      "@odata.id": "/redfish/v1/AccountService#/Oem/OpenBMC",
      "@odata.type": "#OemAccountService.v1_0_0.AccountService",
      "AuthMethods": {
        "BasicAuth": true,
        "Cookie": true,
        "SessionToken": true,
        "TLS": true,
        "XToken": true
      }
    }
  },
  "Roles": {
    "@odata.id": "/redfish/v1/AccountService/Roles"
  },
  "ServiceEnabled": true
}
curl -k -H X-Auth-Token:YuocwiA53jwAzwoj3cGT -X PATCH https://127.0.0.1:2443/redfish/v1/AccountService -d '{AccountLockoutThreshold:10}'
{
  "@Message.ExtendedInfo": [
    {
      "@odata.type": "#Message.v1_1_1.Message",
      "Message": "Successfully Completed Request",
      "MessageArgs": [],
      "MessageId": "Base.1.8.1.Success",
      "MessageSeverity": "OK",
      "Resolution": "None"
    }
  ]
}curl -k -H X-Auth-Token: YuocwiA53jwAzwoj3cGT  -X GET https://127.0.0.1:2443/redfish/v1/AccountService
{
  "@odata.id": "/redfish/v1/AccountService",
  "@odata.type": "#AccountService.v1_5_0.AccountService",
  "AccountLockoutDuration": 600,
  "AccountLockoutThreshold": 10,
  "Accounts": {
    "@odata.id": "/redfish/v1/AccountService/Accounts"
  },
  "Description": "Account Service",
  "Id": "AccountService",
  "LDAP": {
    "Certificates": {
      "@odata.id": "/redfish/v1/AccountService/LDAP/Certificates"
    }
  },
  "MaxPasswordLength": 20,
  "MinPasswordLength": 13,
  "Name": "Account Service",
  "Oem": {
    "OpenBMC": {
      "@odata.id": "/redfish/v1/AccountService#/Oem/OpenBMC",
      "@odata.type": "#OemAccountService.v1_0_0.AccountService",
      "AuthMethods": {
        "BasicAuth": true,
        "Cookie": true,
        "SessionToken": true,
        "TLS": true,
        "XToken": true
      }
    }
  },
  "Roles": {
    "@odata.id": "/redfish/v1/AccountService/Roles"
  },
  "ServiceEnabled": true
}
curl -k -H X-Auth-Token:YuocwiA53jwAzwoj3cGT -X PATCH https://127.0.0.1:2443/redfish/v1/AccountService -d '{AccountLockoutThreshold:1}'
{
  "error": {
    "@Message.ExtendedInfo": [
      {
        "@odata.type": "#Message.v1_1_1.Message",
        "Message": "The request failed due to an internal service error.  The service is still operational.",
        "MessageArgs": [],
        "MessageId": "Base.1.8.1.InternalError",
        "MessageSeverity": "Critical",
        "Resolution": "Resubmit the request.  If the problem persists, consider resetting the service."
      }
    ],
    "code": "Base.1.8.1.InternalError",
    "message": "The request failed due to an internal service error.  The service is still operational."
  }
}
curl -k -H X-Auth-Token: YuocwiA53jwAzwoj3cGT  -X GET https://127.0.0.1:2443/redfish/v1/AccountService
{
  "@odata.id": "/redfish/v1/AccountService",
  "@odata.type": "#AccountService.v1_5_0.AccountService",
  "AccountLockoutDuration": 600,
  "AccountLockoutThreshold": 10,
  "Accounts": {
    "@odata.id": "/redfish/v1/AccountService/Accounts"
  },
  "Description": "Account Service",
  "Id": "AccountService",
  "LDAP": {
    "Certificates": {
      "@odata.id": "/redfish/v1/AccountService/LDAP/Certificates"
    }
  },
  "MaxPasswordLength": 20,
  "MinPasswordLength": 13,
  "Name": "Account Service",
  "Oem": {
    "OpenBMC": {
      "@odata.id": "/redfish/v1/AccountService#/Oem/OpenBMC",
      "@odata.type": "#OemAccountService.v1_0_0.AccountService",
      "AuthMethods": {
        "BasicAuth": true,
        "Cookie": true,
        "SessionToken": true,
        "TLS": true,
        "XToken": true
      }
    }
  },
  "Roles": {
    "@odata.id": "/redfish/v1/AccountService/Roles"
  },
  "ServiceEnabled": true
}

JOURNALCTL LOGS:
root@hgx:~# journalctl | grep user
Jan 01 00:00:08 hgx kernel: Linux version 5.10.36-adadea5 (oe-user@oe-host) (arm-openbmc-linux-gnueabi-gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37.20210721) openbmc#1 SMP Thu Mar 16 10:49:02 UTC 2023
Jan 01 00:00:09 hgx systemd-sysusers[168]: Creating group wheel with gid 990.
Jan 01 00:00:09 hgx systemd-sysusers[168]: Creating group render with gid 989.
Jan 01 00:00:09 hgx systemd-sysusers[168]: Creating group sgx with gid 988.
Jan 01 00:00:09 hgx systemd-sysusers[168]: Creating group nobody with gid 987.
Mar 17 05:54:44 hgx kernel[218]: [    0.000000] Linux version 5.10.36-adadea5 (oe-user@oe-host) (arm-openbmc-linux-gnueabi-gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37.20210721) openbmc#1 SMP Thu Mar 16 10:49:02 UTC 2023
Mar 17 05:54:48 hgx phosphor-user-manager[265]: Group not found
Mar 17 05:54:48 hgx phosphor-user-manager[265]: Group not found
Mar 17 05:54:52 hgx ipmid[311]: Error in reading IPMI user data file
Mar 17 05:54:53 hgx phosphor-discover-system-state[330]: One time not set, check user setting of power policy
Mar 17 05:55:07 hgx systemd-coredump[327]: Process 224 (mctp-demux-daem) of user 0 dumped core.
Mar 17 05:55:19 hgx systemd-coredump[473]: Process 419 (mctp-demux-daem) of user 0 dumped core.
Mar 17 05:55:25 hgx bmcweb[478]: (2023-03-17 05:55:25) [DEBUG "routing.hpp":1439] userName = root userRole = priv-admin
Mar 17 05:55:25 hgx bmcweb[478]: (2023-03-17 05:55:25) [DEBUG "routing.hpp":1439] userName = root userRole = priv-admin
Mar 17 05:55:25 hgx bmcweb[478]: (2023-03-17 05:55:25) [DEBUG "routing.hpp":1439] userName = root userRole = priv-admin
Mar 17 05:55:25 hgx bmcweb[478]: (2023-03-17 05:55:25) [DEBUG "routing.hpp":1439] userName = root userRole = priv-admin
Mar 17 05:55:25 hgx phosphor-user-manager[265]: Setting value lesser than threashold MAX_FAILED_LOGIN_ATTEMPTS is not allowed
Mar 17 05:55:25 hgx phosphor-user-manager[265]: The operation is not allowed
Mar 17 05:55:26 hgx bmcweb[478]: (2023-03-17 05:55:26) [DEBUG "routing.hpp":1439] userName = root userRole = priv-admin
Mar 17 05:55:28 hgx systemd-coredump[580]: Process 555 (mctp-demux-daem) of user 0 dumped core.
Mar 17 05:55:32 hgx systemd-coredump[743]: Process 710 (mctp-demux-daem) of user 0 dumped core.
root@hgx:~# [  OK  ] Started NVIDIA OOB Active Monitoring Logging.

Fixes nvbug https://nvbugs/4029569
dkodihal pushed a commit to NVIDIA/phosphor-user-manager that referenced this issue May 7, 2024
```
Changes Added : Added event loop support in test code

problem : After adding support for sending events from phosphor-user-manager it is obsderved that it is calling sendEvent which internally calls async_send_handler and allocates memeory for context
since the event loop is not present in test code, callback is never called and
the CI was throwing memory leak error

Direct leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x7ffa787b91e7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    openbmc#1 0x7ffa77ad6383 in operator() /usr/local/include/sdbusplus/asio/detail/async_send_handler.hpp:40
    openbmc#2 0x7ffa77ad6383 in async_send<sdbusplus::asio::connection::async_method_call_timed<phosphor::logging::sendEvent(phosphor::logging::MESSAGE_TYPE, sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level, const std::vector<std::__cxx11::basic_string<char> >&, const string&)::<lambda(boost::system::error_code)>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >
    (phosphor::logging::sendEvent(phosphor::logging::MESSAGE_TYPE, sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level, const std::vector<std::__cxx11::basic_string<char> >&, const string&)::<lambda(boost::system::error_code)>&&, const string&, const string&, const string&, const string&, uint64_t, const std::__cxx11::basic_string<char>&, const std::__cxx11::basic_string<char>&, const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&)::<lambda(boost::system::error_code, sdbusplus::message_t&)> > /usr/local/include/sdbusplus/asio/connection.hpp:98
    openbmc#3 0x7ffa77ad6383 in async_method_call_timed<phosphor::logging::sendEvent(phosphor::logging::MESSAGE_TYPE, sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level, const std::vector<std::__cxx11::basic_string<char> >&, const string&)::<lambda(boost::system::error_code)>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > /usr/local/include/sdbusplus/asio/connection.hpp:192
    openbmc#4 0x7ffa77ad6383 in async_method_call<phosphor::logging::sendEvent(phosphor::logging::MESSAGE_TYPE, sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level, const std::vector<std::__cxx11::basic_string<char> >&, const string&)::<lambda(boost::system::error_code)>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > /usr/local/include/sdbusplus/asio/connection.hpp:221
    openbmc#5 0x7ffa77ad6383 in phosphor::logging::sendEvent(phosphor::logging::MESSAGE_TYPE, sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ../lib/redfish_event_log.cpp:112
    openbmc#6 0x55dfba9084a3 in phosphor::certs::Manager::replaceCertificate(phosphor::certs::Certificate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ../certs_manager.cpp:493
    openbmc#7 0x55dfba8ab09d in phosphor::certs::Certificate::replace(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) ../certificate.cpp:315
    openbmc#8 0x55dfba7981e0 in TestBody ../test/certs_manager_test.cpp:677
    openbmc#9 0x7ffa786e3f2e in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /googletest-662fe38e44900c007eccb65a5d2ea19df7bd520e/googletest/src/gtest.cc:2607
    openbmc#10 0x7ffa786e3f2e in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /googletest-662fe38e44900c007eccb65a5d2ea19df7bd520e/googletest/src/gtest.cc:2643

```

Solution : The memory leak error was thrown because the
memory allocated by "async_send_handler" in sdbusplus was not getting de-allocated
because the callback is never getting called called since there was no event loop
present in test code.

Added event loop support in test code

Fixes jira https://jirasw.nvidia.com/browse/DGXOPENBMC-8881
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant