Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
shinpei committed Oct 7, 2011
1 parent 0f05d7f commit 16b73eb
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 78 deletions.
2 changes: 0 additions & 2 deletions shinpei/faults/posix/1-deletefile.k
Expand Up @@ -4,7 +4,6 @@
*/

include "faultinjector.k";

using konoha.posix.*;

class DeleteFileFault extends FaultInstance {
Expand All @@ -22,4 +21,3 @@ class DeleteFileFault extends FaultInstance {
return false;
}
}

23 changes: 23 additions & 0 deletions shinpei/faults/posix/faultsetup.k
@@ -0,0 +1,23 @@
/*
* 1. deletefile
* Shinpei Nakata (c) 2011
*/

class FaultSetup {
String filename;

FaultSetup () {
filename = "";
}

void createFile (String fname, int size) {
filename = fname;
OutputStream ous = new OutputStream(filename,"w");
int wrote_bytes = 0;
while (wrote_bytes < size) {
ous << "@" ;
wrote_bytes++;
}
ous.close();
}
}
71 changes: 0 additions & 71 deletions shinpei/faults/posix/posix.k

This file was deleted.

@@ -1,14 +1,16 @@
using konoha.posix.*;


int main (String[] args) {
Path fpth = null;
String filename = "";
if (|args| > 0) {
filename = args[0];
fpth = file::filename;
}
OUT <<< "filename" <<< EOL;
DFile f = System.fopen(fpth, "r");
int bufsiz = 128;

Bytes buf = new byte[bufsiz];
int total_readsize = 0;
while (total_readsize < 1024) {
Expand Down
26 changes: 22 additions & 4 deletions shinpei/faults/posix/sc1.k
Expand Up @@ -3,13 +3,31 @@
* Shinpei Nakata (c) 2011
*/

using konoha.proc.*;
include "1-deletefile.k"
include "faultsetup.k"

boolean isFaultInject = false;

int main (String[] args)
{
FaultInjector fi = new FaultInjector();
DeleteFileFault fdFault = new DeleteFileFault("hoge");
FaultSetup fs = new FaultSetup();
String input_file = "hoge.txt";
fs.createFile(input_file, 1024);
FaultInjector fi = new FaultInjector();
DeleteFileFault fdFault = new DeleteFileFault(input_file);
fi.addFaultInstance(fdFault);
//wait timinig
fi.loadToLocalTarget();

if (isFaultInject) {
print "injecting...";
fi.loadToLocalTarget();
}
Proc p = new Proc(["/usr/local/bin/konoha", "-a", "sample-posix.k", input_file]);
ins = p.getInputStream();
while (p.isAlive()) {
while ((line = ins.readLine()) != null) {
OUT << line;
}
}
return 0;
}

0 comments on commit 16b73eb

Please sign in to comment.