[so] [TEMA 5] eroare in test.c continuare

Ionutz uvinrg at gmail.com
Sun Feb 11 10:28:56 EET 2007


Deci:

static void check_ram (size_t offset, size_t ppages, size_t checks)
{
    size_t i, j;
    size_t read_val;
    int exp_val;
    int check = 1;

    for (i = 0; i < ppages; i++) {
        lseek (ram_fd, i * p_sz + offset, SEEK_SET);
        for (j = 0; j < checks; j++) {
            exp_val = (i << 16) | (offset + j * 4);
            read (ram_fd, &read_val, 4);

            printf("exp:%08x read:%08x
%d\n",exp_val,read_val,exp_val!=read_val);

            if (exp_val != read_val)
            {
                printf("EROARE!\n");
                check = 0;
            }
            /* you gotta love them binary ops :-D */
            /* check &= !(exp_val ^ read_val); */
        }
    }

    test ("check_ram", check);
}

Output:

test: access......................................................passed
exp:000009cc read:000009cc 1
EROARE!
exp:000009d0 read:000009d0 1
EROARE!
exp:000009d4 read:000009d4 1
EROARE!
exp:000109cc read:000109cc 1
EROARE!
exp:000109d0 read:000109d0 1
EROARE!
exp:000109d4 read:000109d4 1
EROARE!
exp:000209cc read:000209cc 1
EROARE!
exp:000209d0 read:000209d0 1
EROARE!
exp:000209d4 read:000209d4 1
EROARE!
test: check_ram...................................................failed
test: access......................................................passed


On 2/11/07, Razvan Deaconescu <razvand at cs.pub.ro> wrote:
>
> Ionutz wrote:
> > Deci, daca in test.c inlocuiesc toate size_t-urile cu int-uri, imi trece
> > toate testele....altfel pica testele de check_ram si check_swap. Dupa
> > cum ati vazut in mesajul anterior, programul meu functioneaza corect,
> > adica valorile asteptate cu cele gasite sunt identice, doar ca if-ul nu
> > compara corect doua valori size_t, ci doar doua int-uri. Cel putin, la
> > concluzia asta am ajuns eu.
> >
> >
>
> salut!
>
> poti sa faci o afisare cu %08x in loc de %d? vreau sa vad si eu in
> hexazecimal valoarea sa vad daca este cu adevarat diferita
>
> Razvan
> _______________________________________________
> so mailing list
> so at cursuri.cs.pub.ro
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cursuri.cs.pub.ro/pipermail/so/attachments/20070211/8568dd3a/attachment.htm


More information about the so mailing list