diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-06-23T13·27+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-06-23T13·27+0000 |
commit | 5f5cab0ac7c26783a4544feb31708d4f8e0f4a51 (patch) | |
tree | 1ac6bf79f849f385ed38b75377fab010880b8d70 /src/test.cc | |
parent | 85effedca3e4cc3c10ccd835c9ea4fb712418cb9 (diff) |
* A function to restore from a Nix archive.
* addValue() can now import any dumpable FS object.
Diffstat (limited to 'src/test.cc')
-rw-r--r-- | src/test.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/test.cc b/src/test.cc index 2eab91d43bb4..c8e3292e3aee 100644 --- a/src/test.cc +++ b/src/test.cc @@ -23,7 +23,21 @@ struct MySink : DumpSink virtual void operator () (const unsigned char * data, unsigned int len) { /* Don't use cout, it's slow as hell! */ - write(STDOUT_FILENO, (char *) data, len); + if (write(STDOUT_FILENO, (char *) data, len) != (ssize_t) len) + throw SysError("writing to stdout"); + } +}; + + +struct MySource : RestoreSource +{ + virtual void operator () (const unsigned char * data, unsigned int len) + { + ssize_t res = read(STDIN_FILENO, (char *) data, len); + if (res == -1) + throw SysError("reading from stdin"); + if (res != (ssize_t) len) + throw Error("not enough data available on stdin"); } }; @@ -53,6 +67,14 @@ void runTests() cout << (string) hashPath("scratch") << endl; #endif + /* Restoring. */ +#if 1 + MySource source; + restorePath("outdir", source); + cout << (string) hashPath("outdir") << endl; + return; +#endif + /* Set up the test environment. */ mkdir("scratch", 0777); |