VirtualBox

Changeset 9186 in vbox


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

Better testcases for ASMMemFill32 and ASMMemZero32.

File:
1 edited

Legend:

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

    r9185 r9186  
    903903    {
    904904        uint64_t    u64Magic1;
    905         uint8_t     abPage[PAGE_SIZE];
     905        uint8_t     abPage[PAGE_SIZE - 32];
    906906        uint64_t    u64Magic2;
    907907    } Buf1, Buf2, Buf3;
     
    916916    memset(Buf3.abPage, 0x99, sizeof(Buf3.abPage));
    917917    Buf3.u64Magic2 = UINT64_C(0xffffffffffffffff);
    918     ASMMemZero32(Buf1.abPage, PAGE_SIZE);
    919     ASMMemZero32(Buf2.abPage, PAGE_SIZE);
    920     ASMMemZero32(Buf3.abPage, PAGE_SIZE);
     918    ASMMemZero32(Buf1.abPage, sizeof(Buf1.abPage));
     919    ASMMemZero32(Buf2.abPage, sizeof(Buf2.abPage));
     920    ASMMemZero32(Buf3.abPage, sizeof(Buf3.abPage));
    921921    if (    Buf1.u64Magic1 != UINT64_C(0xffffffffffffffff)
    922922        ||  Buf1.u64Magic2 != UINT64_C(0xffffffffffffffff)
     
    929929        g_cErrors++;
    930930    }
    931     for (unsigned i = 0; i < sizeof(Buf1.abPage); i++)
     931    for (unsigned i = 0; i < RT_ELEMENTS(Buf1.abPage); i++)
    932932        if (Buf1.abPage[i])
    933933        {
     
    935935            g_cErrors++;
    936936        }
    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++)
     937    for (unsigned i = 0; i < RT_ELEMENTS(Buf2.abPage); i++)
    944938        if (Buf2.abPage[i])
    945939        {
     
    947941            g_cErrors++;
    948942        }
     943    for (unsigned i = 0; i < RT_ELEMENTS(Buf3.abPage); i++)
     944        if (Buf3.abPage[i])
     945        {
     946            RTPrintf("tstInlineAsm: ASMMemZero32 didn't clear byte at offset %#x!\n", i);
     947            g_cErrors++;
     948        }
    949949}
    950950
     
    957957        uint32_t    au32Page[PAGE_SIZE / 4];
    958958        uint64_t    u64Magic2;
    959     } Buf1, Buf2, Buf3;
     959    } Buf1;
     960    struct
     961    {
     962        uint64_t    u64Magic1;
     963        uint32_t    au32Page[(PAGE_SIZE / 4) - 3];
     964        uint64_t    u64Magic2;
     965    } Buf2;
     966    struct
     967    {
     968        uint64_t    u64Magic1;
     969        uint32_t    au32Page[(PAGE_SIZE / 4) - 1];
     970        uint64_t    u64Magic2;
     971    } Buf3;
    960972
    961973    Buf1.u64Magic1 = UINT64_C(0xffffffffffffffff);
     
    968980    memset(Buf3.au32Page, 0x99, sizeof(Buf3.au32Page));
    969981    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);
     982    ASMMemFill32(Buf1.au32Page, sizeof(Buf1.au32Page), 0xdeadbeef);
     983    ASMMemFill32(Buf2.au32Page, sizeof(Buf2.au32Page), 0xcafeff01);
     984    ASMMemFill32(Buf3.au32Page, sizeof(Buf3.au32Page), 0xf00dd00f);
    973985    if (    Buf1.u64Magic1 != UINT64_C(0xffffffffffffffff)
    974986        ||  Buf1.u64Magic2 != UINT64_C(0xffffffffffffffff)
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