ATF-devel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Difference between normal environment and atf-run



On Sat Oct 09 2010 at 19:24:39 +0300, Adam Hamsik wrote:
> Hi folks,
> 
> [Please keep me on CC I'm not subscribed to this list]
> 
> I'm currently working on a test suite for a device-maper driver based on a 
> RUMP. I have created test in /usr/tests/dev/dm which does something like this
> 
>       dict_in  = 
> prop_dictionary_internalize_from_file("dm_version_cmd.plist");
>       dict_out = prop_dictionary_create();
>       
>       prop_dictionary_externalize_to_pref(dict_in, &prefp);
>       
>       error = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp);
>       if (error < 0)
>               err(1, "Dm control ioctl failed");
> 
> If I run this code in my shell everything works just fine.
> 
> [haad@ dm]$ ./h_dm                                                            
>                                              
> WARNING: 1 error while detecting hardware; check system log.
> [haad@ dm]$ echo $? 
> 0
> 
> But if I run atf-run to test whole test program I will got ENOMEM from 
> rump_sys_ioctl which is weird.
> 
> tc-so:Executing command [ /usr/src/tests/dev/dm/h_dm ]
> tc-se:Fail: incorrect exit status: 1, expected: 0
> tc-se:stdout:
> tc-se:WARNING: 1 error while detecting hardware; check system log.
> tc-se:
> tc-se:stderr:
> tc-se:h_dm: Dm control ioctl failed: Cannot allocate memory

atf-run runs the test in a separate directory to provide a clean test env.
You are trying to open dm_version_cmd.plist from cwd.  You need to pass
the test source directory path to your helper program.

(and you also should check other return values a bit better)

> If I change prefp to be allocated on heap error change from ENOMEM to EIO do 
> you have an idea why atf case behaves differently ?

Probably because the uninitialized garbage in prefp changes.


Home | Main Index | Thread Index | Old Index