• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "DriverTestHelpers.hpp"
6 #include <boost/test/unit_test.hpp>
7 #include <log/log.h>
8 #include "../SystemPropertiesUtils.hpp"
9 
10 BOOST_AUTO_TEST_SUITE(SystemProperiesTests)
11 
BOOST_AUTO_TEST_CASE(SystemProperties)12 BOOST_AUTO_TEST_CASE(SystemProperties)
13 {
14     // Test default value
15     {
16         auto p = __system_property_find("thisDoesNotExist");
17         BOOST_TEST((p == nullptr));
18 
19         int defaultValue = ParseSystemProperty("thisDoesNotExist", -4);
20         BOOST_TEST((defaultValue == -4));
21     }
22 
23     //  Test default value from bad data type
24     {
25         __system_property_set("thisIsNotFloat", "notfloat");
26         float defaultValue = ParseSystemProperty("thisIsNotFloat", 0.1f);
27         BOOST_TEST((defaultValue == 0.1f));
28     }
29 
30     // Test fetching bool values
31     {
32         __system_property_set("myTestBool", "1");
33         bool b = ParseSystemProperty("myTestBool", false);
34         BOOST_TEST((b == true));
35     }
36     {
37         __system_property_set("myTestBool", "0");
38         bool b = ParseSystemProperty("myTestBool", true);
39         BOOST_TEST((b == false));
40     }
41 
42     // Test fetching int
43     {
44         __system_property_set("myTestInt", "567");
45         int i = ParseSystemProperty("myTestInt", 890);
46         BOOST_TEST((i==567));
47     }
48 
49     // Test fetching float
50     {
51         __system_property_set("myTestFloat", "1.2f");
52         float f = ParseSystemProperty("myTestFloat", 3.4f);
53         BOOST_TEST((f==1.2f));
54     }
55 }
56 
57 BOOST_AUTO_TEST_SUITE_END()
58