VirtualBox

Changeset 9185 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 28, 2008 2:02:16 AM (17 years ago)
Author:
vboxsync
Message:

Added testcase for ASMMemFill32 and ASMMemZero32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstInlineAsm.cpp

    r8889 r9185  
    896896        }
    897897}
     898
     899
     900void tstASMMemZero32(void)
     901{
     902    struct
     903    {
     904        uint64_t    u64Magic1;
     905        uint8_t     abPage[PAGE_SIZE];
     906        uint64_t    u64Magic2;
     907    } Buf1, Buf2, Buf3;
     908
     909    Buf1.u64Magic1 = UINT64_C(0xffffffffffffffff);
     910    memset(Buf1.abPage, 0x55, sizeof(Buf1.abPage));
     911    Buf1.u64Magic2 = UINT64_C(0xffffffffffffffff);
     912    Buf2.u64Magic1 = UINT64_C(0xffffffffffffffff);
     913    memset(Buf2.abPage, 0x77, sizeof(Buf2.abPage));
     914    Buf2.u64Magic2 = UINT64_C(0xffffffffffffffff);
     915    Buf3.u64Magic1 = UINT64_C(0xffffffffffffffff);
     916    memset(Buf3.abPage, 0x99, sizeof(Buf3.abPage));
     917    Buf3.u64Magic2 = UINT64_C(0xffffffffffffffff);
     918    ASMMemZero32(Buf1.abPage, PAGE_SIZE);
     919    ASMMemZero32(Buf2.abPage, PAGE_SIZE);
     920    ASMMemZero32(Buf3.abPage, PAGE_SIZE);
     921    if (    Buf1.u64Magic1 != UINT64_C(0xffffffffffffffff)
     922        ||  Buf1.u64Magic2 != UINT64_C(0xffffffffffffffff)
     923        ||  Buf1.u64Magic1 != UINT64_C(0xffffffffffffffff)
     924        ||  Buf1.u64Magic2 != UINT64_C(0xffffffffffffffff)
     925        ||  Buf2.u64Magic1 != UINT64_C(0xffffffffffffffff)
     926        ||  Buf2.u64Magic2 != UINT64_C(0xffffffffffffffff))
     927    {
     928        RTPrintf("tstInlineAsm: ASMMemZero32 violated one/both magic(s)!\n");
     929        g_cErrors++;
     930    }
     931    for (unsigned i = 0; i < sizeof(Buf1.abPage); i++)
     932        if (Buf1.abPage[i])
     933        {
     934            RTPrintf("tstInlineAsm: ASMMemZero32 didn't clear byte at offset %#x!\n", i);
     935            g_cErrors++;
     936        }
     937    for (unsigned i = 0; i < sizeof(Buf2.abPage); i++)
     938        if (Buf1.abPage[i])
     939        {
     940            RTPrintf("tstInlineAsm: ASMMemZero32 didn't clear byte at offset %#x!\n", i);
     941            g_cErrors++;
     942        }
     943    for (unsigned i = 0; i < sizeof(Buf3.abPage); i++)
     944        if (Buf2.abPage[i])
     945        {
     946            RTPrintf("tstInlineAsm: ASMMemZero32 didn't clear byte at offset %#x!\n", i);
     947            g_cErrors++;
     948        }
     949}
     950
     951
     952void tstASMMemFill32(void)
     953{
     954    struct
     955    {
     956        uint64_t    u64Magic1;
     957        uint32_t    au32Page[PAGE_SIZE / 4];
     958        uint64_t    u64Magic2;
     959    } Buf1, Buf2, Buf3;
     960
     961    Buf1.u64Magic1 = UINT64_C(0xffffffffffffffff);
     962    memset(Buf1.au32Page, 0x55, sizeof(Buf1.au32Page));
     963    Buf1.u64Magic2 = UINT64_C(0xffffffffffffffff);
     964    Buf2.u64Magic1 = UINT64_C(0xffffffffffffffff);
     965    memset(Buf2.au32Page, 0x77, sizeof(Buf2.au32Page));
     966    Buf2.u64Magic2 = UINT64_C(0xffffffffffffffff);
     967    Buf3.u64Magic1 = UINT64_C(0xffffffffffffffff);
     968    memset(Buf3.au32Page, 0x99, sizeof(Buf3.au32Page));
     969    Buf3.u64Magic2 = UINT64_C(0xffffffffffffffff);
     970    ASMMemFill32(Buf1.au32Page, PAGE_SIZE, 0xdeadbeef);
     971    ASMMemFill32(Buf2.au32Page, PAGE_SIZE, 0xcafeff01);
     972    ASMMemFill32(Buf3.au32Page, PAGE_SIZE, 0xf00dd00f);
     973    if (    Buf1.u64Magic1 != UINT64_C(0xffffffffffffffff)
     974        ||  Buf1.u64Magic2 != UINT64_C(0xffffffffffffffff)
     975        ||  Buf1.u64Magic1 != UINT64_C(0xffffffffffffffff)
     976        ||  Buf1.u64Magic2 != UINT64_C(0xffffffffffffffff)
     977        ||  Buf2.u64Magic1 != UINT64_C(0xffffffffffffffff)
     978        ||  Buf2.u64Magic2 != UINT64_C(0xffffffffffffffff))
     979    {
     980        RTPrintf("tstInlineAsm: ASMMemFill32 violated one/both magic(s)!\n");
     981        g_cErrors++;
     982    }
     983    for (unsigned i = 0; i < RT_ELEMENTS(Buf1.au32Page); i++)
     984        if (Buf1.au32Page[i] != 0xdeadbeef)
     985        {
     986            RTPrintf("tstInlineAsm: ASMMemFill32 %#x: %#x exepcted %#x\n", i, Buf1.au32Page[i], 0xdeadbeef);
     987            g_cErrors++;
     988        }
     989    for (unsigned i = 0; i < RT_ELEMENTS(Buf2.au32Page); i++)
     990        if (Buf2.au32Page[i] != 0xcafeff01)
     991        {
     992            RTPrintf("tstInlineAsm: ASMMemFill32 %#x: %#x exepcted %#x\n", i, Buf2.au32Page[i], 0xcafeff01);
     993            g_cErrors++;
     994        }
     995    for (unsigned i = 0; i < RT_ELEMENTS(Buf3.au32Page); i++)
     996        if (Buf3.au32Page[i] != 0xf00dd00f)
     997        {
     998            RTPrintf("tstInlineAsm: ASMMemFill32 %#x: %#x exepcted %#x\n", i, Buf3.au32Page[i], 0xf00dd00f);
     999            g_cErrors++;
     1000        }
     1001}
     1002
    8981003
    8991004
     
    10551160    tstASMAtomicAndOrU32();
    10561161    tstASMMemZeroPage();
     1162    tstASMMemZero32();
     1163    tstASMMemFill32();
    10571164    tstASMMath();
    10581165
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette