diff options
| author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-02-19 17:40:24 +0100 |
|---|---|---|
| committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-02-19 17:44:35 +0100 |
| commit | 2d7a4e9dfaee0fc82561bc19c65647b05ad3e0d5 (patch) | |
| tree | 0bfcbfe07ff2720662c943a631f9f09089800589 | |
| parent | 37dff886f4d7b4513bc2772b33455caf2a375065 (diff) | |
| download | rockbox-2d7a4e9dfaee0fc82561bc19c65647b05ad3e0d5.zip rockbox-2d7a4e9dfaee0fc82561bc19c65647b05ad3e0d5.tar.gz rockbox-2d7a4e9dfaee0fc82561bc19c65647b05ad3e0d5.tar.bz2 rockbox-2d7a4e9dfaee0fc82561bc19c65647b05ad3e0d5.tar.xz | |
Fix RockboxInfo() not handling git hashes correctly.
With the transition to git the assumption of the version starting with "r"
isn't true anymore for non-release builds. This caused the wrong strings to be
used when constructing various download URLs.
Remove the test binary which was never intended to be added and fix some
warnings in the test implementation.
Change-Id: I879fdff201cb85f3c89cca73ab6a0514edb5a2df
| -rw-r--r-- | rbutil/rbutilqt/base/rockboxinfo.cpp | 52 | ||||
| -rwxr-xr-x | rbutil/rbutilqt/test/test-rockboxinfo | bin | 568151 -> 0 bytes | |||
| -rw-r--r-- | rbutil/rbutilqt/test/test-rockboxinfo.cpp | 18 |
3 files changed, 38 insertions, 32 deletions
diff --git a/rbutil/rbutilqt/base/rockboxinfo.cpp b/rbutil/rbutilqt/base/rockboxinfo.cpp index 2f56a29..9d8aba6 100644 --- a/rbutil/rbutilqt/base/rockboxinfo.cpp +++ b/rbutil/rbutilqt/base/rockboxinfo.cpp @@ -33,38 +33,40 @@ RockboxInfo::RockboxInfo(QString mountpoint, QString fname) return; // read file contents + QRegExp hash("^Version:\\s+(r?)([0-9a-fM]+)"); + QRegExp version("^Version:\\s+(\\S.*)"); + QRegExp release("^Version:\\s+([0-9\\.]+)"); + QRegExp target("^Target:\\s+(\\S.*)"); + QRegExp features("^Features:\\s+(\\S.*)"); + QRegExp targetid("^Target id:\\s+(\\S.*)"); + QRegExp memory("^Memory:\\s+(\\S.*)"); while (!file.atEnd()) { - QString line = file.readLine(); + QString line = file.readLine().trimmed(); - if(line.contains("Version:")) - { - m_version = line.remove("Version:").trimmed(); - if(m_version.startsWith("r")) { - m_revision = m_version; - m_revision.remove("r").replace(QRegExp("-.+$"), ""); - m_release = ""; - } - else { - m_release = m_version; - m_revision = ""; - } + if(version.indexIn(line) >= 0) { + m_version = version.cap(1); } - else if(line.contains("Target: ")) - { - m_target = line.remove("Target: ").trimmed(); + if(release.indexIn(line) >= 0) { + m_release = release.cap(1); } - else if(line.contains("Features:")) - { - m_features = line.remove("Features:").trimmed(); + if(hash.indexIn(line) >= 0) { + // git hashes are usually at least 7 characters. + // svn revisions are expected to be at least 4 digits. + if(hash.cap(2).size() > 3) + m_revision = hash.cap(2); } - else if(line.contains("Target id:")) - { - m_targetid = line.remove("Target id:").trimmed(); + else if(target.indexIn(line) >= 0) { + m_target = target.cap(1); } - else if(line.contains("Memory:")) - { - m_ram = line.remove("Memory:").trimmed().toInt(); + else if(features.indexIn(line) >= 0) { + m_features = features.cap(1); + } + else if(targetid.indexIn(line) >= 0) { + m_targetid = targetid.cap(1); + } + else if(memory.indexIn(line) >= 0) { + m_ram = memory.cap(1).toInt(); } } diff --git a/rbutil/rbutilqt/test/test-rockboxinfo b/rbutil/rbutilqt/test/test-rockboxinfo Binary files differdeleted file mode 100755 index f881e68..0000000 --- a/rbutil/rbutilqt/test/test-rockboxinfo +++ /dev/null diff --git a/rbutil/rbutilqt/test/test-rockboxinfo.cpp b/rbutil/rbutilqt/test/test-rockboxinfo.cpp index 541d1c1..6fb45fd 100644 --- a/rbutil/rbutilqt/test/test-rockboxinfo.cpp +++ b/rbutil/rbutilqt/test/test-rockboxinfo.cpp @@ -45,10 +45,14 @@ void TestRockboxInfo::testVersion() const struct testvector testdata[] = { - { "Version: r29629-110321", "29629", "r29629-110321", "" }, - { "Version: r29629M-110321", "29629M", "r29629M-110321", "" }, - { "Version: 3.10", "", "3.10", "3.10" }, - { "Version:\t3.10", "", "3.10", "3.10" }, + { "Version: r29629-110321", "29629", "r29629-110321", "" }, + { "Version: r29629M-110321", "29629M", "r29629M-110321", "" }, + { "Version: 3.10", "", "3.10", "3.10" }, + { "Version:\t3.10", "", "3.10", "3.10" }, + { "#Version: r29629-110321", "", "", "" }, + { "Version: e5b1b0f-120218", "e5b1b0f", "e5b1b0f-120218", "" }, + { "Version: e5b1b0fM-120218", "e5b1b0fM", "e5b1b0fM-120218", "" }, + { "#Version: e5b1b0f-120218", "", "", "" }, }; @@ -70,7 +74,7 @@ void TestRockboxInfo::testVersion() void TestRockboxInfo::testTarget() { - unsigned int i, j; + int i, j; QStringList targets; targets << "sansae200" << "gigabeats" << "iriverh100" << "unknown"; QStringList prefix; @@ -94,7 +98,7 @@ void TestRockboxInfo::testTarget() void TestRockboxInfo::testMemory() { - unsigned int i, j; + int i, j; QStringList memsizes; memsizes << "8" << "16" << "32" << "64"; QStringList prefix; @@ -118,7 +122,7 @@ void TestRockboxInfo::testMemory() void TestRockboxInfo::testFeatures() { - unsigned int i, j; + int i, j; QStringList features; features << "backlight_brightness:button_light:dircache:flash_storage" << "pitchscreen:multivolume:multidrive_usb:quickscreen"; |