I wrote assembly wrappers for read/write system calls for an embedded lab, and now I need to test how it handles errors. How can I generate errors in read/write calls? Short counts I can do, but I don't know how to generate errors. Any ideas?
I wrote assembly wrappers for read/write system calls for an embedded lab, and now I need to test how it handles errors. How can I generate errors in read/write calls? Short counts I can do, but I don't know how to generate errors. Any ideas?
Without breaking any micro devices the most common test is buffer overflows. Make sending buffer bigger than the receiving one and vice versa.
Not sure what itCbitC is thinking, but I think what you want to do is return a negative value from read/write, and set errno to whatever you want the error to be. You may want to fill the data (when reading) with recognisable rubbish, so that you can detect cases where the read data is being used even tho' it shouldn't be used.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Wouldn't I just get a short count?
I already wrote the wrappers, I just have to test the things. When read/write return normally everything works, but I have to test how the wrappers behave when read/write return an error. What I'm asking is how I can create a situation in which read or write would return an error condition
Ah, ok. So that would depend on the situation - what OS is it for [1]? You really need to figure out what will cause the OS to give you a failure back - that may be difficult if you can't control the filesystem/device drivers - you can perhaps pass in NULL as the buffer, but some OS's don't check such things, they rely on the memory management to identify bad memory accesses. If there is memory protection for the code area, you could try to pass the address of a function to the read function, but again, it may just cause a SEGV or it's equivalent.
[1] This will probably result in some embedded OS that I have never heard of...
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
As there is not a whole lot of information about the embedded system I was assuming things and one was to disable a device driven by the microcontroller w/o getting the system into a hung state.
Apart from that some of the important things would be the installed OS; does it use virtual memory?