1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <general_test/running_info.h> 18 19 #include <shared/send_message.h> 20 21 namespace general_test { 22 queryByAppId()23bool RunningInfo::queryByAppId() { 24 return mPlatformInfo.queryByAppId(&mRunningInfo); 25 } 26 queryByInstanceId()27bool RunningInfo::queryByInstanceId() { 28 return mPlatformInfo.queryByInstanceId(&mRunningInfo); 29 } 30 validate(uint32_t appVersion)31bool RunningInfo::validate(uint32_t appVersion) { 32 bool result; 33 if (mRunningInfo.version != appVersion) { 34 nanoapp_testing::sendFatalFailureToHost( 35 "Running info version does not match app version"); 36 result = false; 37 } else if (mRunningInfo.appId != NANOAPP_ID) { 38 nanoapp_testing::sendFatalFailureToHost( 39 "Running info appId does not match build constant"); 40 result = false; 41 } else if (mRunningInfo.version != NANOAPP_VERSION) { 42 nanoapp_testing::sendFatalFailureToHost( 43 "Running info version does not match build constant"); 44 result = false; 45 } else { 46 result = mPlatformInfo.validate(mRunningInfo.appId, 47 mRunningInfo.instanceId); 48 } 49 50 return result; 51 } 52 53 } // namespace general_test 54