ANSI C code testing

P

praveen

Hi,

I am writing c code for ATMEL 8051 core in ANSI c. we are using KEIL
compiler for it. I want to test my c code and improve my programming
skills. Can any one suggest the software tool that can test my c code
for runtime errors?
 
I

Ian Collins

praveen said:
Hi,

I am writing c code for ATMEL 8051 core in ANSI c. we are using KEIL
compiler for it. I want to test my c code and improve my programming
skills. Can any one suggest the software tool that can test my c code
for runtime errors?
Unit tests?
 
M

Micah Cowan

praveen said:
Hi,

I am writing c code for ATMEL 8051 core in ANSI c. we are using KEIL
compiler for it. I want to test my c code and improve my programming
skills. Can any one suggest the software tool that can test my c code
for runtime errors?

Ian Collins gave the most correct answer. The number of potential kinds
of runtime errors are infinite. Some kinds can certainly be discovered
programatically, some can't. Some can be determined by examining the
source code, some can't. Errors in logic, for instance, are runtime
errors, and yet completely impossible to catch automatically in some
general way. These, especially, benefit from the use of unit tests.

Memory abuse is a common runtime error, and fortunately there are many
tools available for at least /helping/ to catch these. Tools like
Valgrind or Electric Fence will help here.

A good "lint" program can also be very useful for this sort of thing.
 
M

Malcolm

Micah Cowan said:
Ian Collins gave the most correct answer. The number of potential kinds
of runtime errors are infinite. Some kinds can certainly be discovered
programatically, some can't. Some can be determined by examining the
source code, some can't. Errors in logic, for instance, are runtime
errors, and yet completely impossible to catch automatically in some
general way. These, especially, benefit from the use of unit tests.

Memory abuse is a common runtime error, and fortunately there are many
tools available for at least /helping/ to catch these. Tools like
Valgrind or Electric Fence will help here.

A good "lint" program can also be very useful for this sort of thing.
The snag is that embedded code that interacts with hardware is difficult to
unit test, except in an emulator, and an emulator is as hard to write as the
actual program.

Separate out the IO from the the logic, or as I put it, the procedures from
the functions. The logic can be unit tested. The IO will probaly need
testing on hardware.
 
J

jacob navia

Malcolm a écrit :
The snag is that embedded code that interacts with hardware is difficult to
unit test, except in an emulator, and an emulator is as hard to write as the
actual program.

But there is an emulator for the 8051 ALREADY written,
as I pointed out in my answer.

The "expanded" version of that minuscule chip has 256
BYTES of RAM...

With so few bytes available even a "brute force" approach
to testing could work...
 
I

Ian Collins

Malcolm said:
The snag is that embedded code that interacts with hardware is difficult to
unit test, except in an emulator, and an emulator is as hard to write as the
actual program.

But often way more fun!
Separate out the IO from the the logic, or as I put it, the procedures from
the functions. The logic can be unit tested. The IO will probaly need
testing on hardware.

Agreed, assuming you neither have nor want to write an emulation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top