Browse Source

make check will segfault most times with this minimal code

segfaults
Pjotr Prins 3 years ago
parent
commit
74a12056ee
  1. 55
      test/read_bam_file.d

55
test/read_bam_file.d

@ -35,55 +35,18 @@ import std.exception;
import std.math;
import std.typetuple;
import std.regex;
import core.memory;
void main() {
auto bam = new BamReader("test/data/ex1_header.bam");
auto reads = bam["chr2"][150 .. 160]; // region chr2:149-158
auto pileup = makePileup(reads,
false, // reads don't contain MD tags
155, 158); // specify [start, end) interval
BamReader bam;
auto fn = buildPath(dirName(__FILE__), "data", "ex1_header.bam");
foreach (i; 0 .. 60)
{
auto fn = buildPath(dirName(__FILE__), "data", "b.sam");
auto sam = new SamReader(fn);
auto writer = new BamWriter("/dev/null", 0);
writer.writeSamHeader(sam.header);
writer.writeReferenceSequenceInfo(sam.reference_sequences);
foreach (r; sam.reads)
writer.writeRecord(r);
writer.finish();
bam = new BamReader(fn);
assert(bam.header.format_version == "1.3");
}
{
auto fn = buildPath(dirName(__FILE__), "data", "bins.bam");
auto bf = new BamReader(fn);
}
import core.memory;
stderr.writeln("**** Calling GC");
GC.collect();
stderr.writeln("**** Past calling GC");
{
auto fn = buildPath(dirName(__FILE__), "data", "ex1_header.bam");
auto bf = new BamReader(fn);
assert(bf.header.format_version == "1.3");
assert(bf.header.sorting_order == SortingOrder.coordinate);
assert(bf.header.sequences.length == 2);
assert(bf.header.getSequenceIndex("chr1") == 0);
assert(bf.header.sequences["chr2"].length == 1584);
auto fn2 = buildPath(dirName(__FILE__), "data", "bins.bam");
auto bf2 = new BamReader(fn2);
assert(bf2.header.sorting_order == SortingOrder.unknown);
assert(bf2.header.sequences.length == 3);
assert(bf2.header.read_groups.length == 0);
assert(bf2.header.getSequenceIndex("large") == 2);
assert(bf2.header.sequences["small"].length == 65536);
}
// Time to kick in GC
import core.memory;
stderr.writeln("**** Calling GC");
GC.collect();
stderr.writeln("**** Past calling GC");
// stderr.writeln("**** Calling GC final");
// GC.collect();
// stderr.writeln("**** Past calling GC final");
}
Loading…
Cancel
Save