Scanimage -T backend tester [patch]

Nick Lamb (njl98r@ecs.soton.ac.uk)
Sun, 28 Feb 1999 21:42:30 +0000 (GMT)

This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.

--1318610500-15712637-920238150=:9019
Content-Type: TEXT/PLAIN; charset=US-ASCII

Well, I no longer have the original detailed explanation for this patch,
but I suspect that it is archived somewhere...

Although I obviously don't have the opportunity to compare the in-use
quality of different backends, my instinct is that they could be a lot
better. So I wrote a test for the problem that bit me when trying to
learn how SANE works -- buffer over/underflows.

The patch is attached here, and for MIME impaired people, it is available
from http://www.staff.ecs.soton.ac.uk/~njl98r/

This patch adds a new option scanimage -T, which will test that the
backend chosen (or the default backend) complies with the SANE
standard. In this version the test only checks for the behaviour with
regard to sane_read(...), ie that the backend will never write more
data than requested, and that it correctly reports how much data it
wrote to the buffer.

In the same vein, I'm working on a backend which offers a number of
virtual devices, each of which can offer a static image which is
generated by a simple algorithm. This is intended to be a test for a
user who isn't sure that SANE is working, or for frontend writers who
don't have different hardware available for testing features.

I really like the SANE standard, and I hope this stuff helps.

Nick.

--1318610500-15712637-920238150=:9019
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=scanimage-test-patch
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.3.96.990228214230.9019B@chef.ecs.soton.ac.uk>
Content-Description: Scanimage patch

LS0tIHNjYW5pbWFnZS5jLm9sZAlUaHUgRGVjIDMxIDEzOjIzOjU1IDE5OTgN
CisrKyBzY2FuaW1hZ2UuYwlUaHUgRGVjIDMxIDEzOjM4OjA0IDE5OTgNCkBA
IC01OSwxOCArNTksMTkgQEANCiAgIHsibGlzdC1kZXZpY2VzIiwgbm9fYXJn
dW1lbnQsIE5VTEwsICdMJ30sDQogICB7ImhlbHAiLCBub19hcmd1bWVudCwg
TlVMTCwgJ2gnfSwNCiAgIHsidmVyYm9zZSIsIG5vX2FyZ3VtZW50LCBOVUxM
LCAnd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zogY2FzZSAnVic6IGNhc2UgJ1QnOg0KIAkgICAgICAvKiBwcmV2aW91c2x5
IGhhbmRsZWQgb3B0aW9ucyAqLw0KIAkgICAgICBicmVhazsNCiANCkBAIC0x
MjMxLDcgKzEzMzQsMTAgQEANCiAgIHNpZ25hbCAoU0lHUElQRSwgc2lnaGFu
ZGxlcik7DQogICBzaWduYWwgKFNJR1RFUk0sIHNpZ2hhbmRsZXIpOw0KIA0K
LSAgc2Nhbl9pdCAoKTsNCisgIGlmICh0ZXN0ID09IDApIA0KKyAgICBzY2Fu
X2l0ICgpOw0KKyAgZWxzZQ0KKyAgICB0ZXN0X2l0ICgpOw0KIA0KICAgc2Fu
ZV9jbG9zZSAoZGV2aWNlKTsNCiANCg==
--1318610500-15712637-920238150=:9019--

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com