--- a/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/SBSv2QueryTests.java Wed May 19 10:09:01 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/SBSv2QueryTests.java Wed May 19 17:52:30 2010 -0500
@@ -18,6 +18,7 @@
package com.nokia.carbide.cdt.builder.test;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
@@ -34,6 +35,7 @@
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.osgi.framework.Version;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -42,19 +44,27 @@
import org.xml.sax.InputSource;
import org.xml.sax.helpers.DefaultHandler;
+import com.nokia.carbide.cdt.builder.test.sandbox.ISBSv2ConfigData;
+import com.nokia.carbide.cdt.builder.test.sandbox.ISBSv2QueryData;
+import com.nokia.carbide.cdt.builder.test.sandbox.SBSv2ConfigData;
+import com.nokia.carbide.cdt.builder.test.sandbox.SBSv2QueryData;
import com.nokia.carbide.cpp.internal.api.sdk.SBSv2Utils;
+import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
import com.nokia.cpp.internal.api.utils.core.Logging;
public class SBSv2QueryTests extends BaseTest {
- private static HashMap<String, String> sbsAliasMap;
+ private static ISBSv2QueryData sbsAliasBaseQuery;
+
private long startTime;
private final String QUERY_PRODUCTS_COMMAND = "--query=products";
private final String QUERY_CONFIG_COMMAND = "--query=config";
private final String QUERY_COMMAND = "--query=aliases";
+ private final String SDK_ID1 = "K_92_WK12"; // SDK with additional aliases and products
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -74,28 +84,97 @@
public void testQueryAliases() throws Exception {
startTime = System.currentTimeMillis();
-
- List<String> argList = new ArrayList<String>();
- argList.add(QUERY_COMMAND);
-
- String queryResult = getSBSQueryOutput(argList, null);
- System.out.println("Query output from " + QUERY_COMMAND + " : " + queryResult);
- assertTrue("No output found from " + QUERY_COMMAND, queryResult.length() > 0);
-
- sbsAliasMap = parseQueryAliasResult(queryResult);
-
- assertTrue("No configs were successfully parsed from the sbs commmand : " + QUERY_COMMAND, sbsAliasMap.size() > 0);
-
- String aliasLookup = sbsAliasMap.get("armv5_udeb"); // look-up some known build alias
- assertNotNull(aliasLookup);
-
- aliasLookup = sbsAliasMap.get("there_is_no_way_this_would_be_config_name");
- assertNull(aliasLookup);
-
+ if (sbsAliasBaseQuery == null){
+ sbsAliasBaseQuery = getSBSv2QueryData();
+ }
System.out.println("Time for testQueryProductsFromSDKs(): " + getTimingStats());
+ List<ISBSv2ConfigData> baseConfigs = sbsAliasBaseQuery.getBaseSBSConfigurations();
+
+ for (ISBSv2ConfigData config : baseConfigs){
+ assertTrue("Configuration should be true : " + config.toString(), config.isBaseConfig());
+ }
+ assertEquals(18, baseConfigs.size());
+
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByAlias("armv5_udeb"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByAlias("armv5_urel"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByAlias("winscw_udeb"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByAlias("winscw_urel"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByAlias("armv5_urel_gcce4_4_1"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByAlias("armv5_udeb_gcce4_4_1"));
+
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByMeaning("arm.v5.udeb.rvct2_2"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByMeaning("arm.v5.urel.rvct2_2"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByMeaning("winscw_base.winscw_debug"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByMeaning("winscw_base.winscw_release"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByMeaning("arm.v5.urel.gcce4_4_1"));
+ assertNotNull(sbsAliasBaseQuery.getSBSConfigByMeaning("arm.v5.udeb.gcce4_4_1"));
+
+ assertNull(sbsAliasBaseQuery.getSBSConfigByAlias("armv5_udeb.foobar"));
+ assertNull(sbsAliasBaseQuery.getSBSConfigByMeaning("arm.v5.udeb.foo.bar"));
+
+ // Get the Raptor configs that are defined in an SDK
+ ISymbianSDK sdk = SDKCorePlugin.getSDKManager().getSDK(SDK_ID1, false);
+ assertNotNull("Missing SDK on your system: " + SDK_ID1, sdk);
+ List<ISBSv2ConfigData> sdkSpecificConfigs = sbsAliasBaseQuery.getSDKSpecificConfigData(sdk);
+ assertEquals(10, sdkSpecificConfigs.size());
+
+ // Get the union of the base Raptor configs and the SDK
+ List<ISBSv2ConfigData> allSDKConfigUnion = sbsAliasBaseQuery.getAllConfigurationsForSDK(sdk);
+ assertEquals(28, allSDKConfigUnion.size());
}
+ private ISBSv2QueryData getSBSv2QueryData() {
+ List<String> argListConfigQuery = new ArrayList<String>();
+ List<String> argListProductQuery = new ArrayList<String>();
+ argListConfigQuery.add(QUERY_COMMAND);
+ SBSv2QueryData sbsQueryData = new SBSv2QueryData();
+
+ /////// Invoke Raptor once with no EPOCROOT
+ Properties envVars = EnvironmentReader.getEnvVars();
+ envVars.setProperty("EPOCROOT", "FOOBAR");
+ String queryResult = getSBSQueryOutput(argListConfigQuery, createEnvStringList(envVars));
+
+ HashMap<String, String> sbsAliasMap = parseQueryAliasResult(queryResult);
+
+ for (String aliasKey : sbsAliasMap.keySet()){
+ String meaning = sbsAliasMap.get(aliasKey);
+ SBSv2ConfigData oneSBSConfig = new SBSv2ConfigData(aliasKey, meaning, null);
+ sbsQueryData.addConfigurationData(oneSBSConfig);
+ }
+
+ /////// Do for each SDK to build up the alias list...
+ for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()){
+ IPath epocRoot = new Path(sdk.getEPOCROOT());
+ if ((sdk.getOSVersion().getMajor() <= 9 && sdk.getOSVersion().getMinor() <5)
+ || !epocRoot.toFile().exists()){
+
+ continue; // skip it, the sdk is not supported or broken
+ }
+
+ envVars = EnvironmentReader.getEnvVars();
+ envVars.setProperty("EPOCROOT", sdk.getEPOCROOT());
+
+ queryResult = getSBSQueryOutput(argListConfigQuery, createEnvStringList(envVars));
+
+ sbsAliasMap = parseQueryAliasResult(queryResult);
+
+ for (String aliasKey : sbsAliasMap.keySet()){
+ String meaning = sbsAliasMap.get(aliasKey);
+ SBSv2ConfigData oneSBSConfig = new SBSv2ConfigData(aliasKey, meaning, sdk);
+ sbsQueryData.addConfigurationData(oneSBSConfig);
+ }
+
+ // Now get the products for each SDK
+ argListProductQuery.add(QUERY_PRODUCTS_COMMAND);
+ queryResult = getSBSQueryOutput(argListProductQuery, createEnvStringList(envVars));
+ List<String> productList = parseQueryProductsResults(queryResult);
+ sbsQueryData.addProductListForSDK(sdk, productList);
+ }
+
+ return sbsQueryData;
+ }
+
/**
* TODO: The SBS API FOR THIS QUERY IS UNDER CONSTRUCTION.....
* TODO; This test should be run on individual %EPOCROOT% values
@@ -103,18 +182,17 @@
*/
public void testQueryConfigs() throws Exception {
- assertNotNull(sbsAliasMap);
+ assertNotNull(sbsAliasBaseQuery);
startTime = System.currentTimeMillis();
List<String> argList = new ArrayList<String>();
- for (String key : sbsAliasMap.keySet()){
- argList.add(QUERY_CONFIG_COMMAND + "[" + key + "]");
+ for (ISBSv2ConfigData baseConfig: sbsAliasBaseQuery.getBaseSBSConfigurations()){
+ argList.add(QUERY_CONFIG_COMMAND + "[" + baseConfig.getBuildAlias() + "]");
}
String queryResult = getSBSQueryOutput(argList, null);
- System.out.println("Query output from " + QUERY_CONFIG_COMMAND + " : " + queryResult);
assertTrue("No output found from " + QUERY_CONFIG_COMMAND, queryResult.length() > 0);
HashMap<String, String> outputMap = parseQueryConfigResults(queryResult);
@@ -130,33 +208,16 @@
* @throws Exception
*/
public void testQueryProductsFromSDKs() throws Exception {
-
-
- startTime = System.currentTimeMillis();
-
- List<String> argList = new ArrayList<String>();
-
- argList.add(QUERY_PRODUCTS_COMMAND);
-
- // TODO: Just hard-coding a known SDK that has variants set up.
- Properties envVars = EnvironmentReader.getEnvVars();
- envVars.setProperty("EPOCROOT", "K:");
-
- String queryResult = getSBSQueryOutput(argList, createEnvStringList(envVars));
- System.out.println("Query output from " + QUERY_PRODUCTS_COMMAND + " : " + queryResult);
- assertTrue("No output found from " + QUERY_PRODUCTS_COMMAND, queryResult.length() > 0);
-
- List<String> productList = parseQueryProductsResults(queryResult);
- assertTrue("No products were found in query for : " + QUERY_PRODUCTS_COMMAND, productList.size() > 0);
-
- System.out.println("Time for testQueryProductsFromSDKs(): " + getTimingStats());
+ ISymbianSDK sdk = SDKCorePlugin.getSDKManager().getSDK(SDK_ID1, false);
+ assertNotNull("Missing SDK on your system: " + SDK_ID1, sdk);
+ List<String> products = sbsAliasBaseQuery.getProductsForSDK(sdk);
+ assertEquals(38, products.size());
}
public void testStressQueryTest() throws Exception {
long stressTestStartTime = System.currentTimeMillis();
-
testQueryAliases();
testQueryConfigs();
@@ -364,7 +425,11 @@
if (minutes > 0){
return "\nTotal Time: " + minutes + " min, " + seconds + " sec\n";
} else {
- return "\nTotal Time: " + seconds + " sec\n";
+ if (seconds == 1){
+ return "\nTotal Time: " + millisec + " msec\n";
+ } else {
+ return "\nTotal Time: " + seconds + " sec\n";
+ }
}
} else {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/sandbox/ISBSv2ConfigData.java Wed May 19 17:52:30 2010 -0500
@@ -0,0 +1,31 @@
+package com.nokia.carbide.cdt.builder.test.sandbox;
+
+import java.util.List;
+
+import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+
+/** Data that describes the meaning of a single build configuration */
+public interface ISBSv2ConfigData {
+
+ String getBuildAlias();
+
+ String getMeaning();
+
+ String getReleaseDirectory();
+
+ ISBSv2ConfigPreprocessorInfo getBuildData();
+
+ String getTraditionalTarget();
+
+ String getTraditionalPlatform();
+
+ List<ISymbianSDK> getSupportedSDKs();
+
+ void addSupportedSDK(ISymbianSDK sdk);
+
+ /**
+ * Is this configuration supported by the base Raptor install?
+ * @return
+ */
+ boolean isBaseConfig();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/sandbox/ISBSv2ConfigPreprocessorInfo.java Wed May 19 17:52:30 2010 -0500
@@ -0,0 +1,21 @@
+package com.nokia.carbide.cdt.builder.test.sandbox;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+
+public interface ISBSv2ConfigPreprocessorInfo {
+
+ List<String> getMacroList();
+
+ List<IPath> getSystemIncludes();
+
+ IPath getVariantConfig();
+
+ String getCompiler();
+
+ IPath getCompilerPrefix();
+
+ ISBSv2ConfigData getSBSv2QueryConfigData();
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/sandbox/ISBSv2QueryData.java Wed May 19 17:52:30 2010 -0500
@@ -0,0 +1,24 @@
+package com.nokia.carbide.cdt.builder.test.sandbox;
+
+import java.util.List;
+
+import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+
+public interface ISBSv2QueryData {
+
+ void addConfigurationData(ISBSv2ConfigData configData);
+
+ List<ISBSv2ConfigData> getAllConfigurationsForSDK(ISymbianSDK sdk);
+
+ List<ISBSv2ConfigData> getSDKSpecificConfigData(ISymbianSDK sdk);
+
+ List<ISBSv2ConfigData> getBaseSBSConfigurations();
+
+ List<String> getProductsForSDK(ISymbianSDK sdk);
+
+ void addProductListForSDK(ISymbianSDK sdk, List<String> products);
+
+ ISBSv2ConfigData getSBSConfigByAlias(String aliase);
+
+ ISBSv2ConfigData getSBSConfigByMeaning(String string);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/sandbox/SBSv2ConfigData.java Wed May 19 17:52:30 2010 -0500
@@ -0,0 +1,81 @@
+package com.nokia.carbide.cdt.builder.test.sandbox;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+
+public class SBSv2ConfigData implements ISBSv2ConfigData {
+
+ String buildAlias;
+ String meaning;
+ /** A configuration that was discovered without using a valid EPOCROOT during an sbs query */
+ private boolean isBaseConfig;
+ List<ISymbianSDK> supportedSDKs = new ArrayList<ISymbianSDK>();
+
+ public SBSv2ConfigData(String buildAlias, String meaning, ISymbianSDK sdk){
+ this.buildAlias = buildAlias;
+ this.meaning = meaning;
+ if (sdk != null){
+ supportedSDKs.add(sdk);
+ } else {
+ this.isBaseConfig = true;
+ }
+ }
+
+ @Override
+ public String getBuildAlias() {
+ return buildAlias;
+ }
+
+ @Override
+ public String getMeaning() {
+ return meaning;
+ }
+
+
+ @Override
+ public String getReleaseDirectory() {
+ // TODO Here's this may need to be dynamically determined...
+ //Maybe need ISymbianSDK param?
+ return null;
+ }
+
+ @Override
+ public ISBSv2ConfigPreprocessorInfo getBuildData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getTraditionalTarget() {
+ // TODO NOT SURE IF THIS WILL BE NEEDED
+ return null;
+ }
+
+ @Override
+ public String getTraditionalPlatform() {
+ // TODO NOT SURE IF THIS WILL BE NEEDED
+ return null;
+ }
+
+ @Override
+ public List<ISymbianSDK> getSupportedSDKs() {
+ return supportedSDKs;
+ }
+
+ @Override
+ public void addSupportedSDK(ISymbianSDK sdk) {
+ supportedSDKs.add(sdk);
+ }
+
+ @Override
+ public boolean isBaseConfig() {
+ return isBaseConfig;
+ }
+
+ public String toString(){
+ return "Alias = " + buildAlias + " : Meaning = " + meaning;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/sandbox/SBSv2QueryData.java Wed May 19 17:52:30 2010 -0500
@@ -0,0 +1,109 @@
+package com.nokia.carbide.cdt.builder.test.sandbox;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+
+public class SBSv2QueryData implements ISBSv2QueryData {
+
+
+ /** alias ==> build config data Map*/
+ HashMap<String, ISBSv2ConfigData> sbsBuildConfigMap = new HashMap<String, ISBSv2ConfigData>();
+ HashMap<ISymbianSDK, List<String>> sdkProductVariantList = new HashMap<ISymbianSDK, List<String>>();
+
+ @Override
+ public void addConfigurationData(ISBSv2ConfigData configData) {
+
+ String buildAlias = configData.getBuildAlias();
+ if (null == sbsBuildConfigMap.get(buildAlias)){
+ sbsBuildConfigMap.put(buildAlias, configData);
+ } else {
+ // build alias already exists, just add it as a supported SDK
+ ISBSv2ConfigData updateConfig = sbsBuildConfigMap.get(buildAlias);
+ for (ISymbianSDK sdk : configData.getSupportedSDKs()){
+ // Add to the list of already supported SDKs, if any
+ updateConfig.addSupportedSDK(sdk);
+ }
+ sbsBuildConfigMap.put(buildAlias, updateConfig);
+ }
+ }
+
+ @Override
+ public List<ISBSv2ConfigData> getBaseSBSConfigurations() {
+ List<ISBSv2ConfigData> baseSBSConfigs = new ArrayList<ISBSv2ConfigData>();
+
+ // get all the base configurations...
+ for (String key : sbsBuildConfigMap.keySet()) {
+ ISBSv2ConfigData configData = sbsBuildConfigMap.get(key);
+ if (configData.isBaseConfig()) {
+ baseSBSConfigs.add(configData);
+ }
+ }
+
+ return baseSBSConfigs;
+ }
+
+ @Override
+ public List<ISBSv2ConfigData> getSDKSpecificConfigData(ISymbianSDK sdk) {
+ List<ISBSv2ConfigData> configsForSDK = new ArrayList<ISBSv2ConfigData>();
+
+ // get all the base configurations...
+ for (String key : sbsBuildConfigMap.keySet()) {
+ ISBSv2ConfigData configData = sbsBuildConfigMap.get(key);
+ if (configData.isBaseConfig()) {
+ continue;
+ }
+ // Not a Raptor-defined config, see if the SDK defined it
+ if (sdk != null){
+ if (configData.getSupportedSDKs().contains(sdk)){
+ configsForSDK.add(configData);
+ }
+ }
+ }
+
+ return configsForSDK;
+ }
+
+ @Override
+ public List<ISBSv2ConfigData> getAllConfigurationsForSDK(ISymbianSDK sdk) {
+ List<ISBSv2ConfigData> allConfigs = new ArrayList<ISBSv2ConfigData>();
+ allConfigs.addAll(getBaseSBSConfigurations());
+ allConfigs.addAll(getSDKSpecificConfigData(sdk));
+ return allConfigs;
+ }
+
+ @Override
+ public List<String> getProductsForSDK(ISymbianSDK sdk) {
+ return sdkProductVariantList.get(sdk);
+ }
+
+ @Override
+ public void addProductListForSDK(ISymbianSDK sdk, List<String> products) {
+ if (null == sdkProductVariantList.get(sdk) ||
+ sdkProductVariantList.size() == 0){
+
+ sdkProductVariantList.put(sdk, products);
+ }
+
+ }
+
+ @Override
+ public ISBSv2ConfigData getSBSConfigByAlias(String alias) {
+ return sbsBuildConfigMap.get(alias);
+ }
+
+ @Override
+ public ISBSv2ConfigData getSBSConfigByMeaning(String string) {
+ ISBSv2ConfigData configData = null;
+ for (String key : sbsBuildConfigMap.keySet()){
+ if (sbsBuildConfigMap.get(key).getMeaning().equals(string)){
+ return sbsBuildConfigMap.get(key);
+ }
+ }
+
+ return configData;
+ }
+
+}