Deci:<br><br>static void check_ram (size_t offset, size_t ppages, size_t checks)<br>{<br> size_t i, j;<br> size_t read_val;<br> int exp_val;<br> int check = 1;<br><br> for (i = 0; i < ppages; i++) {<br> lseek (ram_fd, i * p_sz + offset, SEEK_SET);
<br> for (j = 0; j < checks; j++) {<br> exp_val = (i << 16) | (offset + j * 4);<br> read (ram_fd, &read_val, 4);<br><br> printf("exp:%08x read:%08x %d\n",exp_val,read_val,exp_val!=read_val);
<br> <br> if (exp_val != read_val)<br> {<br> printf("EROARE!\n");<br> check = 0;<br> }<br> /* you gotta love them binary ops :-D */
<br> /* check &= !(exp_val ^ read_val); */<br> }<br> }<br><br> test ("check_ram", check);<br>}<br><br>Output:<br><br>test: access......................................................passed
<br>exp:000009cc read:000009cc 1<br>EROARE!<br>exp:000009d0 read:000009d0 1<br>EROARE!<br>exp:000009d4 read:000009d4 1<br>EROARE!<br>exp:000109cc read:000109cc 1<br>EROARE!<br>exp:000109d0 read:000109d0 1<br>EROARE!<br>exp:000109d4 read:000109d4 1
<br>EROARE!<br>exp:000209cc read:000209cc 1<br>EROARE!<br>exp:000209d0 read:000209d0 1<br>EROARE!<br>exp:000209d4 read:000209d4 1<br>EROARE!<br>test: check_ram...................................................failed<br>test: access......................................................passed
<br><br><br><div><span class="gmail_quote">On 2/11/07, <b class="gmail_sendername">Razvan Deaconescu</b> <<a href="mailto:razvand@cs.pub.ro">razvand@cs.pub.ro</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ionutz wrote:<br>> Deci, daca in test.c inlocuiesc toate size_t-urile cu int-uri, imi trece<br>> toate testele....altfel pica testele de check_ram si check_swap. Dupa<br>> cum ati vazut in mesajul anterior, programul meu functioneaza corect,
<br>> adica valorile asteptate cu cele gasite sunt identice, doar ca if-ul nu<br>> compara corect doua valori size_t, ci doar doua int-uri. Cel putin, la<br>> concluzia asta am ajuns eu.<br>><br>><br><br>salut!
<br><br>poti sa faci o afisare cu %08x in loc de %d? vreau sa vad si eu in<br>hexazecimal valoarea sa vad daca este cu adevarat diferita<br><br>Razvan<br>_______________________________________________<br>so mailing list<br>
<a href="mailto:so@cursuri.cs.pub.ro">so@cursuri.cs.pub.ro</a><br><a href="http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so">http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so</a><br></blockquote></div><br>