Re: [PATCH RESEND v20 7/8] tests/numa: Add case for QMP build HMAT
On Fri, 13 Dec 2019 09:19:28 +0800 Tao Xu wrote: > Check configuring HMAT usecase > > Acked-by: Markus Armbruster > Suggested-by: Igor Mammedov > Signed-off-by: Tao Xu Reviewed-by: Igor Mammedov > --- > > Changes in v20: > - Fix the wrong target in pc_hmat_erange_cfg > - Use g_assert_true and g_assert_false to replace g_assert > (Thomas and Markus) > > Changes in v19: > - Add some fail cases for hmat-cache when level=0 > > Changes in v18: > - Rewrite the lines over 80 characters > > Chenges in v17: > - Add some fail test cases (Igor) > --- > tests/numa-test.c | 213 ++ > 1 file changed, 213 insertions(+) > > diff --git a/tests/numa-test.c b/tests/numa-test.c > index 8de8581231..17dd807d2a 100644 > --- a/tests/numa-test.c > +++ b/tests/numa-test.c > @@ -327,6 +327,216 @@ static void pc_dynamic_cpu_cfg(const void *data) > qtest_quit(qs); > } > > +static void pc_hmat_build_cfg(const void *data) > +{ > +QTestState *qs = qtest_initf("%s -nodefaults --preconfig -machine > hmat=on " > + "-smp 2,sockets=2 " > + "-m 128M,slots=2,maxmem=1G " > + "-object memory-backend-ram,size=64M,id=m0 " > + "-object memory-backend-ram,size=64M,id=m1 " > + "-numa node,nodeid=0,memdev=m0 " > + "-numa node,nodeid=1,memdev=m1,initiator=0 " > + "-numa cpu,node-id=0,socket-id=0 " > + "-numa cpu,node-id=0,socket-id=1", > + data ? (char *)data : ""); > + > +/* Fail: Initiator should be less than the number of nodes */ > +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 2, 'target': 0," > +" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); > + > +/* Fail: Target should be less than the number of nodes */ > +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 2," > +" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); > + > +/* Fail: Initiator should contain cpu */ > +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 1, 'target': 0," > +" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); > + > +/* Fail: Data-type mismatch */ > +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," > +" 'hierarchy': \"memory\", 'data-type': \"write-latency\"," > +" 'bandwidth': 524288000 } }"))); > +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," > +" 'hierarchy': \"memory\", 'data-type': \"read-bandwidth\"," > +" 'latency': 5 } }"))); > + > +/* Fail: Bandwidth should be 1MB (1048576) aligned */ > +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," > +" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," > +" 'bandwidth': 1048575 } }"))); > + > +/* Configuring HMAT bandwidth and latency details */ > +g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," > +" 'hierarchy': \"memory\", 'data-type': \"access-latency\"," > +" 'latency': 1 } }")));/* 1 ns */ > +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," > +" 'hierarchy': \"memory\", 'data-type': \"access-latency\"," > +" 'latency': 5 } }")));/* Fail: Duplicate configuration */ > +g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," > +" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," > +" 'bandwidth': 68717379584 } }")));/* 65534 MB/s */ > +g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," > +" 'hierarchy': \"memory\", 'data-type': \"access-latency\"," > +" 'latency': 65534 } }")));/* 65534 ns */ > +g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': > 'set-numa-node'," > +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," > +" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," > +" 'bandwidth': 34358689792 }
[PATCH RESEND v20 7/8] tests/numa: Add case for QMP build HMAT
Check configuring HMAT usecase Acked-by: Markus Armbruster Suggested-by: Igor Mammedov Signed-off-by: Tao Xu --- Changes in v20: - Fix the wrong target in pc_hmat_erange_cfg - Use g_assert_true and g_assert_false to replace g_assert (Thomas and Markus) Changes in v19: - Add some fail cases for hmat-cache when level=0 Changes in v18: - Rewrite the lines over 80 characters Chenges in v17: - Add some fail test cases (Igor) --- tests/numa-test.c | 213 ++ 1 file changed, 213 insertions(+) diff --git a/tests/numa-test.c b/tests/numa-test.c index 8de8581231..17dd807d2a 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -327,6 +327,216 @@ static void pc_dynamic_cpu_cfg(const void *data) qtest_quit(qs); } +static void pc_hmat_build_cfg(const void *data) +{ +QTestState *qs = qtest_initf("%s -nodefaults --preconfig -machine hmat=on " + "-smp 2,sockets=2 " + "-m 128M,slots=2,maxmem=1G " + "-object memory-backend-ram,size=64M,id=m0 " + "-object memory-backend-ram,size=64M,id=m1 " + "-numa node,nodeid=0,memdev=m0 " + "-numa node,nodeid=1,memdev=m1,initiator=0 " + "-numa cpu,node-id=0,socket-id=0 " + "-numa cpu,node-id=0,socket-id=1", + data ? (char *)data : ""); + +/* Fail: Initiator should be less than the number of nodes */ +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 2, 'target': 0," +" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + +/* Fail: Target should be less than the number of nodes */ +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 2," +" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + +/* Fail: Initiator should contain cpu */ +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 1, 'target': 0," +" 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + +/* Fail: Data-type mismatch */ +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," +" 'hierarchy': \"memory\", 'data-type': \"write-latency\"," +" 'bandwidth': 524288000 } }"))); +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," +" 'hierarchy': \"memory\", 'data-type': \"read-bandwidth\"," +" 'latency': 5 } }"))); + +/* Fail: Bandwidth should be 1MB (1048576) aligned */ +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," +" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," +" 'bandwidth': 1048575 } }"))); + +/* Configuring HMAT bandwidth and latency details */ +g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," +" 'hierarchy': \"memory\", 'data-type': \"access-latency\"," +" 'latency': 1 } }")));/* 1 ns */ +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," +" 'hierarchy': \"memory\", 'data-type': \"access-latency\"," +" 'latency': 5 } }")));/* Fail: Duplicate configuration */ +g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," +" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," +" 'bandwidth': 68717379584 } }")));/* 65534 MB/s */ +g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," +" 'hierarchy': \"memory\", 'data-type': \"access-latency\"," +" 'latency': 65534 } }")));/* 65534 ns */ +g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," +" 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," +" 'bandwidth': 34358689792 } }")));/* 32767 MB/s */ + +/* Fail: node_id should be less than the number of nodes */ +g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," +" 'arguments': { 'type': 'hmat-cache', 'node-id': 2, 'size': 10240," +" 'level': 1, 'associativity': \"direct\", 'policy