@@ -19,8 +19,8 @@ check(const vector<string>& input, const vector<string>& output)
1919{
2020 Mockup::set_mode (Mockup::Mode::PLAYBACK);
2121 Mockup::set_command ({ PVS_BIN, " --reportformat" , " json" , " --config" , " log { command_names = 0 prefix = \"\" }" ,
22- " --units" , " b" , " --nosuffix" , " --all" , " --options" , " pv_name,pv_uuid,vg_name,vg_uuid,pv_attr,pe_start" }
23- , input);
22+ " --units" , " b" , " --nosuffix" , " --all" , " --options" , " pv_name,pv_uuid,vg_name,vg_uuid,pv_attr,pe_start" },
23+ input);
2424
2525 CmdPvs cmd_pvs;
2626
@@ -35,6 +35,27 @@ check(const vector<string>& input, const vector<string>& output)
3535}
3636
3737
38+ void
39+ check (const string& pv_name, const vector<string>& input, const vector<string>& output)
40+ {
41+ Mockup::set_mode (Mockup::Mode::PLAYBACK);
42+ Mockup::set_command ({ PVS_BIN, " --reportformat" , " json" , " --config" , " log { command_names = 0 prefix = \"\" }" ,
43+ " --units" , " b" , " --nosuffix" , " --all" , " --options" , " pv_name,pv_uuid,vg_name,vg_uuid,pv_attr,pe_start" ,
44+ pv_name }, input);
45+
46+ CmdPvs cmd_pvs (pv_name);
47+
48+ ostringstream parsed;
49+ parsed.setf (std::ios::boolalpha);
50+ parsed << cmd_pvs;
51+
52+ string lhs = parsed.str ();
53+ string rhs = boost::join (output, " \n " ) + " \n " ;
54+
55+ BOOST_CHECK_EQUAL (lhs, rhs);
56+ }
57+
58+
3859BOOST_AUTO_TEST_CASE (parse1)
3960{
4061 vector<string> input = {
@@ -57,6 +78,30 @@ BOOST_AUTO_TEST_CASE(parse1)
5778}
5879
5980
81+ BOOST_AUTO_TEST_CASE (parse2)
82+ {
83+ // The device reported pv name can be different from the provided pv name.
84+
85+ vector<string> input = {
86+ " {" ,
87+ " \" report\" : [" ,
88+ " {" ,
89+ " \" pv\" : [" ,
90+ " {\" pv_name\" :\" /dev/md127\" , \" pv_uuid\" :\" nA8nKb-VSgN-fRvo-pGqm-pRBl-MX3M-Hf2sjT\" , \" vg_name\" :\"\" , \" vg_uuid\" :\"\" , \" pv_attr\" :\" ---\" , \" pe_start\" :\" 1048576\" }" ,
91+ " ]" ,
92+ " }" ,
93+ " ]" ,
94+ " }"
95+ };
96+
97+ vector<string> output = {
98+ " pv:{ pv-name:/dev/md127 pv-uuid:nA8nKb-VSgN-fRvo-pGqm-pRBl-MX3M-Hf2sjT vg-name: vg-uuid: pe-start:1048576 }"
99+ };
100+
101+ check (" /dev/md/a" , input, output);
102+ }
103+
104+
60105BOOST_AUTO_TEST_CASE (parse_missing)
61106{
62107 vector<string> input = {
0 commit comments