Skip to content

Commit

Permalink
Bisect demo added.
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarov-yuriy committed Mar 23, 2016
1 parent 8154618 commit f614184
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 15 deletions.
27 changes: 26 additions & 1 deletion src/main/groovy/Starter.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.strangeway.disttest.Distro
import org.strangeway.disttest.Initramfs
import org.strangeway.disttest.KernelBinary
import org.strangeway.disttest.KernelRepo
import org.strangeway.disttest.KernelSourcePool
import org.strangeway.disttest.Utils

Expand Down Expand Up @@ -52,8 +53,32 @@ class Starter {
}
}

public static void bisectDemo(){
KernelSourcePool kernelSourcePool = new KernelSourcePool()
Initramfs initramfs = new Initramfs("hello.sh")
initramfs.getArtifact()

String[] commits = KernelRepo.getVersionBetweenTags("v3.18", "v3.18.28")
int broken = 0
int working = commits.length-1
while(broken+1 != working){
int testIndex = (broken+working)/2
KernelBinary kernelBinary = new KernelBinary("linux-3.18", commits[testIndex], "acpi", kernelSourcePool)
println "Testing commit #$testIndex($broken..$working)"+commits[testIndex]
Distro distro = new Distro(kernelBinary, initramfs)
String res = distro.run()
distro.close()
println "Res: $res\n"
if(res == "<KILLED>"){
broken = testIndex
}else{
working = testIndex
}
}
}

public static void main(String[] args) {
threadedDemo()
bisectDemo()
}
}

23 changes: 23 additions & 0 deletions src/main/groovy/org/strangeway/disttest/KernelRepo.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
package org.strangeway.disttest

class KernelRepo {
private static final gitUrl = "git@server.home:/home/git/linux-stable.git"

static String getRepoPath() {
File repoDir = new File("kernelRepo/linux-stable")
if (repoDir.isDirectory()) {
return repoDir.getPath()
}
Process process = new ProcessBuilder("git", "clone", "--no-checkout", gitUrl).directory(new File("kernelRepo")).start();
process.consumeProcessOutput()
process.waitFor()
assert 0 == process.exitValue()
return repoDir.getPath()
}

static String[] getVersionBetweenTags(String from, String to){
Process process = new ProcessBuilder("git", "log", "--pretty=format:%H", "$from..$to").directory(new File(getRepoPath())).start();
StringBuilder sout = new StringBuilder()
StringBuilder serr = new StringBuilder()
process.consumeProcessOutput(sout, serr)
process.waitFor()
assert 0 == process.exitValue()
return sout.tokenize("\n").reverse()
}
}
17 changes: 3 additions & 14 deletions src/main/groovy/org/strangeway/disttest/KernelSource.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,18 @@ import java.util.regex.Matcher
class KernelSource implements Task {
private percentage = 0
private static final basePath = "kernelSources"
private static final gitUrl = "git@server.home:/home/git/linux-stable.git"
String version
String commit
int slot
String tmpMountPoint
String aufsMountPoint
KernelRepo kernelRepo

KernelSource(String _version, String _commit, int _slot) {
version = _version
commit = _commit
slot = _slot
}

static String getRepoPath() {
File repoDir = new File("kernelRepo/linux-stable")
if (repoDir.isDirectory()) {
return repoDir.getPath()
}
Process process = new ProcessBuilder("git", "clone", "--no-checkout", gitUrl).directory(new File("kernelRepo")).start();
process.consumeProcessOutput()
process.waitFor()
assert 0 == process.exitValue()
return repoDir.getPath()
kernelRepo = new KernelRepo()
}

String getSeedPath(String version) {
Expand Down Expand Up @@ -92,7 +81,7 @@ class KernelSource implements Task {
}
String seed = getSeedPath(version)
percentage = 20
String repo = getRepoPath()
String repo = kernelRepo.getRepoPath()
percentage = 40
String tmp = getTmpPath()
percentage = 60
Expand Down

0 comments on commit f614184

Please sign in to comment.