From mboxrd@z Thu Jan 1 00:00:00 1970 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> MIME-Version: 1.0 Date: Fri, 13 Aug 2010 11:46:54 -0600 From: EBo In-Reply-To: <6c97cc385db794bd736f6ea0cd505989@plug.quanstro.net> References: <669f246aba1d324e377a93d730962f41@swcp.com> <6c97cc385db794bd736f6ea0cd505989@plug.quanstro.net> Message-ID: <79d728670c7d6a03e9acc7fb3c756777@swcp.com> User-Agent: RoundCube Webmail/0.3.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [9fans] =?utf-8?q?read=282=29_problem_on_p9p=3F?= Topicbox-Message-UUID: 48237306-ead6-11e9-9d60-3106f5b1d025 > you haven't explanined what the arguments to test do, but > you appear to be mixing strcmp idioms. i think you wish either > > test(strcmp(test_str, buf) == 0, 4, "check value\n"); > > or > test(!strcmp(test_str, buf), 4, "check value\n"); Right. Sorry... The declaration for test is: void test(int bool, int space, ...); where bool is the test case to prepend a pass/fail message in front of the used defined message printed by vfprint. Space is a pretty printing addon that prints n spaces before the print message -- it makes it easier to read. The test you pointed out was a bad test. Thanks for catching that! The real problem was the test before it: ret = read(dtf, buf, strlen buf); test(strlen(tst_str)==ret,4, "read back from var\n"); Read actually correctly reads the file correctly (which the next test verifies), but since I asked it to read 1K bytes when the message length is only 39, read returns 0 instead of 39 and sets the file's offset to the end of file as I would have expected. I also should add if I did not before, this is on plan9port. EBo --