"James Harris" <
james.h...@gmail.com> wrote in message
news:5edc0d2b-bca5-459f...@a6g2000vbf.googlegroups.com...
> Testing is boring, right? ... Right!
>
Is this you volunteering? ;-)
> Testing our programs can be tedious.
>
> As a principle
> ==============
>
> I have long been a fan of the *principle* of having a suite of
> tests for a given software or hardware project. The benefits
> of having such a test suite include
>
> * Verifies the effect of the unit under test
> * Saves programmer time:
> - the machine, not the programmer, tests the program
> - a test defined once can be run repeatedly
> * Helps the programmer in other ways
> - checks that enhancements haven't broken something
> - i.e. regression testing
> - gives confidence in the initial code and in any changes
> - mechanises something which is boring for a person to do
> * Provides an extra level of verification
> - when planning, helps to see a slightly higher level
> - carries out a cross-check of test and program
> - either may be faulty; checks one against the other
>
> Downsides? Of course, tests need to be written in the first
> place.
...
> That can cost a significant amount of time and the amount of
> testing code can be greater than the amount of code being
> tested.
Yes.
> Nevertheless, for most projects, being able to run those tests
> repeatedly has to far outweigh the cost of writing the test code
> in the first place.
>
Sometimes.
> Writing tests is still boring (though not as much as having to
> carry out all the tests by hand)
Yes.
> but a test once written should need
> relatively little maintenance.
Maybe.
> Not only but also
> =================
>
> I recently came across or was reminded of another potential
> benefit of having a test suite, namely that if the tests are
> written before the code they are to test they can be used to
> guide the development of the code. This is the idea of
> test-driven development.
>
> [link]
Ok. Sarcasm, "guide" vs. "constrained"...
I just skimmed the start of the article. It seems similar to
other development concepts: design-by-contract, unit testing, code
refactoring, Agile software management, object oriented
programming, etc. (all are on Wikipedia, if you're interested...)
> In this case a complete suite of tests *define* what the product
> is to do before the product is developed. This can help with
> development of the idea and help us focus on what the product's
> effect should be. And, of course, those tests can remain with
> the product for years to come, being used to verify that changes
> do not break something that once worked. That's got to be a big
> benefit, right!
>
Yes, it can be. However, it won't catch errors without a test
for it... I.e., this implies much prescience or experience or
overkill on the part of the test-suite creator.
I'm not sure that this is suitable for all products and code ...
E.g., you don't get to chose what BIOS your end-user uses. You
can't test it. You can't be sure your BIOS testsuite correctly
emulates it or your application correctly uses it. Ditto for
CD-ROM drive, motherboard chipset, audio chipset, or VESA video
BIOS, etc. I.e., you have to code to a well defined software or
hardware interface. If their equipment is not 100% compatible, it
becomes their problem, unfortunately. That even plagues MS with
their OS installs for Win9x, WinXP ,etc. They try to do too much,
use too many new hardware features, and find and install all
hardware upfront. They could just install keyboard, mouse, video,
and boot drive. Then, once Windows is running, let a Windows app
run to detect, install, reconfigure, and upgrade everything else.
Instead, you get near infinite reboots, one for every time their
installer chokes on something...
> So to the OS
> ============
>
> Given the above, do any of you guys have an interest in
> discussing whether such a set of ideas could be feasibly
> applied to development of our OS developments?
>
At the moment, I can't see where or how exactly I'd apply it...
It could be useful somewhere. I tend to do the "program it, test
it, fix it, repeat" approach. It's simple, easy, quick. I've
only seen a few instances where complications arose later on. For
a few parts of my OS, I first wrote DOS code in C that I could
test with DOS. Later, I merged and rewrote (perhaps
refactored...?) the code to fit into my OS.
What I did want, and perhaps still do, was a BIOS function tester
which tests all critical BIOS functions and hardware support for
OS needs or bootloader needs, e.g., e820h, a20, Int 13h
functionality, VGA registers available, VESA 2.0 present?, PM BIOS
interfaces (VESA, PCI), etc. Of course, I'd construct a much
larger list of function calls from the BIOS calls used by
bootloaders and installers for MS products, FreeBSD, Linux, etc.
> As, I hope, illustrated above the principle has much to
> recommend it but it is practical?
It can be done. With one company I worked for, we coded and
manually tested. After that, we ran an entire days worth of
incoming data through the system to see if there were any errant
changes in the final data. If that was fine, we ran other days
until everyone of note was reasonably confident no mistakes had
been made. The input and output data were "sufficient" to ensure
"correctness" of the system's operation. Of course, it was
important to them financially, they had many programmers, and so
they implemented such a test platform.
So far, the scope of your desire to use this (or similar)
concept(s) is unlimited. Where did you plan on using it? There
are likely places and situations where it'll work very well, and
others not so much. Things that are outside your control, or
outside your application space could be problematic. How much
uniformity or coherence or correlation do you expect between the
OSes this test-suite could test? There must be some commonality.
E.g., in DOS you can insert a small TSR to trap all calls to the
BIOS, but you can't do that with Windows or Linux. Of course,
they probably aren't using BIOS so much. But, if you wanted to do
so for them, you'd have to code a device driver or something
similar. Hypothetically, you might introduce problems with the
way the OS is supposed to function by creating such a driver,
e.g., glitch, crash, hang.
> Even if you have an interest only in the principle I would
> welcome your feedback. I have some more to add - some
> of it exciting, IMHO, if you have an interest in setting up
> tests for your OS - but won't add more to your reading matter
> just yet.
>
At this point, my stalled OS project can't execute any apps. It
could be compiled in if it's coded in C or assembly. I'm not sure
exactly what I could test though... Everything I coded for the OS
proper, was tested at some point. I know a few pieces of code are
broken for different hardware. Some OSes are likely to be
advanced and will have file I/O, hardware, graphics, etc while
others are likely to be bare-bones and incomplete, like mine.
Personally, I prefer stand-alone code that compiles/assembles and
executes under a "low-overhead" OS like DOS. Of course, that
wouldn't really test my OS... It's also good if it can be
compiled under a few OSes. Boot-up code which tests things is
good too. However, no OS is loaded yet either...
Rod Pemberton