MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_memzone_free

Function test_memzone_free

dpdk/app/test/test_memzone.c:871–962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

869}
870
871static int
872test_memzone_free(void)
873{
874 const struct rte_memzone **mz;
875 int i;
876 char name[20];
877 int rc = -1;
878
879 mz = rte_calloc("memzone_test", rte_memzone_max_get() + 1,
880 sizeof(struct rte_memzone *), 0);
881 if (!mz) {
882 printf("Fail allocating memzone test array\n");
883 return rc;
884 }
885
886 mz[0] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone0"), 2000,
887 SOCKET_ID_ANY, 0);
888 mz[1] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone1"), 4000,
889 SOCKET_ID_ANY, 0);
890
891 if (mz[0] > mz[1])
892 goto exit_test;
893 if (!rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone0")))
894 goto exit_test;
895 if (!rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone1")))
896 goto exit_test;
897
898 if (rte_memzone_free(mz[0])) {
899 printf("Fail memzone free - tempzone0\n");
900 goto exit_test;
901 }
902 if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone0"))) {
903 printf("Found previously free memzone - tempzone0\n");
904 goto exit_test;
905 }
906 mz[2] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone2"), 2000,
907 SOCKET_ID_ANY, 0);
908
909 if (mz[2] > mz[1]) {
910 printf("tempzone2 should have gotten the free entry from tempzone0\n");
911 goto exit_test;
912 }
913 if (rte_memzone_free(mz[2])) {
914 printf("Fail memzone free - tempzone2\n");
915 goto exit_test;
916 }
917 if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone2"))) {
918 printf("Found previously free memzone - tempzone2\n");
919 goto exit_test;
920 }
921 if (rte_memzone_free(mz[1])) {
922 printf("Fail memzone free - tempzone1\n");
923 goto exit_test;
924 }
925 if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone1"))) {
926 printf("Found previously free memzone - tempzone1\n");
927 goto exit_test;
928 }

Callers 1

test_memzoneFunction · 0.85

Calls 8

rte_callocFunction · 0.85
rte_memzone_max_getFunction · 0.85
rte_memzone_reserveFunction · 0.85
rte_memzone_lookupFunction · 0.85
rte_memzone_freeFunction · 0.85
snprintfFunction · 0.85
rte_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected