[363] | 1 | /*
|
---|
| 2 | * TOPPERS/JSP Kernel
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 4 | * Just Standard Profile Kernel
|
---|
| 5 | *
|
---|
| 6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
| 8 | *
|
---|
| 9 | * ä¸è¨èä½æ¨©è
|
---|
| 10 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
| 11 | * ã«ãã£ã¦å
|
---|
| 12 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
| 13 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
| 14 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
| 15 | å¸ï¼ä»¥ä¸ï¼
|
---|
| 16 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 17 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 18 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 19 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 20 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 21 | * ç¨ã§ããå½¢ã§åé
|
---|
| 22 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 23 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 24 | * è
|
---|
| 25 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 26 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 27 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 28 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 29 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 30 | * ã¨ï¼
|
---|
| 31 | * (a) åé
|
---|
| 32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 33 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 34 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 35 | * (b) åé
|
---|
| 36 | å¸ã®å½¢æ
|
---|
| 37 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 38 | * å ±åãããã¨ï¼
|
---|
| 39 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 40 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 41 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 42 | 責ãããã¨ï¼
|
---|
| 43 | *
|
---|
| 44 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 45 | ã
|
---|
| 46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
| 47 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
| 48 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
| 49 | *
|
---|
| 50 | * @(#) $Id: filecontainer.cpp,v 1.11 2003/12/20 06:51:58 takayuki Exp $
|
---|
| 51 | */
|
---|
| 52 |
|
---|
| 53 | #ifdef _MSC_VER
|
---|
| 54 | #pragma warning(disable:4786) //ãããã°æååã255æåã«åãè©°ãã
|
---|
| 55 | #endif
|
---|
| 56 |
|
---|
| 57 | #include "base/filecontainer.h"
|
---|
| 58 | #include <memory.h>
|
---|
| 59 | #include <fstream>
|
---|
| 60 |
|
---|
| 61 | using namespace std;
|
---|
| 62 |
|
---|
| 63 | namespace {
|
---|
| 64 | /* 符å·ãªã10é²æååã®ãã¼ã¹ */
|
---|
| 65 | char * parse_uint(char * src, unsigned int * dest, unsigned int default_value = 0)
|
---|
| 66 | {
|
---|
| 67 | int result = 0;
|
---|
| 68 |
|
---|
| 69 | if(*src < '0' || *src > '9') {
|
---|
| 70 | *dest = default_value;
|
---|
| 71 | return src;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | do {
|
---|
| 75 | result = result * 10 + *(src++) - '0';
|
---|
| 76 | } while(*src >= '0' && *src <='9');
|
---|
| 77 |
|
---|
| 78 | *dest = result;
|
---|
| 79 | return src;
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | /* å¤æ°æ
|
---|
| 84 | å ±ã®èªã¿è¾¼ã¿ */
|
---|
| 85 | void FileContainer::attachInfo(const string & filename) throw(Exception)
|
---|
| 86 | {
|
---|
| 87 | char buffer[256];
|
---|
| 88 | fstream file;
|
---|
| 89 |
|
---|
| 90 | char * work;
|
---|
| 91 | struct tagVariableInfo info;
|
---|
| 92 |
|
---|
| 93 | memset(&info, 0, sizeof(info));
|
---|
| 94 |
|
---|
| 95 | file.open(filename.c_str(), ios::in);
|
---|
| 96 | if(!file.is_open()) {
|
---|
| 97 | ExceptionMessage("Structure information file(%) was not found. ","æ§é ä½æ
|
---|
| 98 | å ±ãã¡ã¤ã«(%)ãè¦ã¤ããã¾ãã ") << filename << throwException;
|
---|
| 99 | return;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | while(!file.eof())
|
---|
| 103 | {
|
---|
| 104 | file.get(buffer, 256);
|
---|
| 105 |
|
---|
| 106 | if(!file.fail()) {
|
---|
| 107 | switch(buffer[0])
|
---|
| 108 | {
|
---|
| 109 | case 's':
|
---|
| 110 | {
|
---|
| 111 | unsigned int address = 0;
|
---|
| 112 | unsigned int size = 0;
|
---|
| 113 |
|
---|
| 114 | work = buffer+1;
|
---|
| 115 | while(*work != ',' && *work != '\x0')
|
---|
| 116 | work++;
|
---|
| 117 | if(*work != '\x0') {
|
---|
| 118 | *work = '\x0';
|
---|
| 119 | work = parse_uint(work+1,&size);
|
---|
| 120 | work = parse_uint(work+1,&address);
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | info.address = static_cast<address_t>(address);
|
---|
| 124 | info.size = static_cast<size_t>(size);
|
---|
| 125 | variableinfo[string(buffer+1)] = info;
|
---|
| 126 | break;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | case 'd': //èå¥ååã¯ç¡è¦
|
---|
| 130 | break;
|
---|
| 131 |
|
---|
| 132 | default:
|
---|
| 133 | ExceptionMessage("Unknown information type identifier found - [%]","æªç¥ã®åèå¥å - [%]") << buffer[0] << throwException;
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 | else
|
---|
| 137 | file.clear();
|
---|
| 138 |
|
---|
| 139 | file.get();
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | file.close();
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | /* å¤æ°æ
|
---|
| 146 | å ±ã®åå¾ */
|
---|
| 147 | struct FileContainer::tagVariableInfo FileContainer::getVariableInfo(const string & name) throw(Exception)
|
---|
| 148 | {
|
---|
| 149 | map<string, tagVariableInfo>::const_iterator scope;
|
---|
| 150 |
|
---|
| 151 | scope = variableinfo.find(name);
|
---|
| 152 | if(scope == variableinfo.end()) {
|
---|
| 153 | ExceptionMessage("Operation against the unknwon symbol [%] was rejected.","ä¸æãªã·ã³ãã«å [%] ã®æ
|
---|
| 154 | å ±ãåå¾ãããã¨ãã¦ãã¾ã") << name << throwException;
|
---|
| 155 |
|
---|
| 156 | struct tagVariableInfo dummy;
|
---|
| 157 | memset(&dummy, 0, sizeof(dummy));
|
---|
| 158 | return dummy;
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | return scope->second;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 |
|
---|
| 165 | /* ã³ã³ã¹ãã©ã¯ã¿ (ã·ã³ãã«åãæå®ãã¦åæå) */
|
---|
| 166 | TargetVariableBase::TargetVariableBase(const std::string & sym) throw()
|
---|
| 167 | : address(0), size(0), offset(0), structure_size(0), loaded(false)
|
---|
| 168 | {
|
---|
| 169 | try{
|
---|
| 170 | FileContainer * fc = FileContainer::getInstance();
|
---|
| 171 | address = fc->getSymbolAddress(sym);
|
---|
| 172 | size = fc->getVariableInfo(sym).size;
|
---|
| 173 | structure_size = size;
|
---|
| 174 | }
|
---|
| 175 | catch(...) {
|
---|
| 176 | address = 0;
|
---|
| 177 | size = 0;
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | /* ã³ã³ã¹ãã©ã¯ã¿ (ã·ã³ãã«å, ãã¼ã¿é·ãæå®ãã¦åæå) */
|
---|
| 182 | TargetVariableBase::TargetVariableBase(const string & sym, size_t _size) throw()
|
---|
| 183 | : address(0), size(_size), offset(0), structure_size(_size), loaded(false)
|
---|
| 184 | {
|
---|
| 185 | try{
|
---|
| 186 | FileContainer * fc = FileContainer::getInstance();
|
---|
| 187 | address = fc->getSymbolAddress(sym);
|
---|
| 188 | }
|
---|
| 189 | catch(...) {
|
---|
| 190 | address = 0;
|
---|
| 191 | size = 0;
|
---|
| 192 | }
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | /* ã³ã³ã¹ãã©ã¯ã¿ (ã·ã³ãã«åãã¡ã³ãåãæå®ãã¦åæå) */
|
---|
| 196 | TargetVariableBase::TargetVariableBase(const string & sym, const string & sz) throw()
|
---|
| 197 | : address(0), size(0), offset(0), structure_size(0), loaded(false)
|
---|
| 198 | {
|
---|
| 199 | try{
|
---|
| 200 | FileContainer * fc = FileContainer::getInstance();
|
---|
| 201 | address = fc->getSymbolAddress(sym); //æ§é ä½ã®å
|
---|
| 202 | é ã¢ãã¬ã¹
|
---|
| 203 | size = fc->getVariableInfo(sz).size; //ã¡ã³ãå¤æ°ã®é·ã
|
---|
| 204 | offset = static_cast<size_t>(fc->getVariableInfo(sz).address); //ã¡ã³ãå¤æ°ã®ãªãã»ãã
|
---|
| 205 | structure_size = fc->getVariableInfo(sym).size; //æ§é ä½ã®é·ã
|
---|
| 206 | }
|
---|
| 207 | catch(...) {
|
---|
| 208 | address = 0;
|
---|
| 209 | size = 0;
|
---|
| 210 | }
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | /* ã³ãã¼ã³ã³ã¹ãã©ã¯ã¿ */
|
---|
| 214 | TargetVariableBase::TargetVariableBase(const TargetVariableBase & src) throw()
|
---|
| 215 | : address(0), size(0), offset(0), structure_size(0), loaded(false)
|
---|
| 216 | {
|
---|
| 217 | if(src.isValid()) {
|
---|
| 218 | address = src.address;
|
---|
| 219 | size = src.size;
|
---|
| 220 | offset = src.offset;
|
---|
| 221 | structure_size = src.structure_size;
|
---|
| 222 | loaded = false;
|
---|
| 223 | }
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 |
|
---|
| 227 | /* ãªãã¸ã§ã¯ãå
|
---|
| 228 | 容ã®åå¾ */
|
---|
| 229 | void TargetVariableBase::loadContent(void * dest, size_t dest_size) throw(Exception)
|
---|
| 230 | {
|
---|
| 231 | char * buffer = 0;
|
---|
| 232 |
|
---|
| 233 | try {
|
---|
| 234 | if(isValid()) {
|
---|
| 235 | buffer = new char[getSize()];
|
---|
| 236 | FileContainer * fc = FileContainer::getInstance();
|
---|
| 237 |
|
---|
| 238 | fc->loadContents(buffer, getAddress() + getOffset(), getSize());
|
---|
| 239 | if(fc->getByteOrder() != FileContainer::HOSTORDER)
|
---|
| 240 | changeEndian(buffer, getSize());
|
---|
| 241 |
|
---|
| 242 | if(size < dest_size)
|
---|
| 243 | memset(dest, 0, dest_size);
|
---|
| 244 | else if(size > dest_size)
|
---|
| 245 | ExceptionMessage("[TargetVariableBase::loadContent] Destination storage is too small to store the contents.","[TargetVariableBase::loadContent] åºåå
|
---|
| 246 | ãããã¡ã®ãµã¤ãºãå°ãããã¾ã").throwException();
|
---|
| 247 | memcpy(dest, buffer, getSize());
|
---|
| 248 |
|
---|
| 249 | delete [] buffer;
|
---|
| 250 | loaded = true;
|
---|
| 251 | }
|
---|
| 252 | else {
|
---|
| 253 | ExceptionMessage("loadContent was performed with an illegal target variable.","ä¸æ£ãªã¿ã¼ã²ããå¤æ°æ
|
---|
| 254 | å ±ã§loadContentãå¼ã°ãã¾ãã").throwException();
|
---|
| 255 | }
|
---|
| 256 | }
|
---|
| 257 | catch(bad_alloc &) {
|
---|
| 258 | ExceptionMessage("No available memory [%B]","ã¡ã¢ãªä¸è¶³ã§ã [%B]") << (unsigned int)getSize() << throwException;
|
---|
| 259 | }
|
---|
| 260 | catch(Exception &) {
|
---|
| 261 | if(buffer)
|
---|
| 262 | delete [] buffer;
|
---|
| 263 | throw;
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | /* ãã¤ããªã¼ãã®å¤æ´ */
|
---|
| 268 | void TargetVariableBase::changeEndian(char * buffer, size_t size) throw()
|
---|
| 269 | {
|
---|
| 270 | char * tail = buffer + size - 1;
|
---|
| 271 |
|
---|
| 272 | while(buffer < tail) {
|
---|
| 273 | char temporary = *buffer;
|
---|
| 274 | *buffer = *tail;
|
---|
| 275 | *tail = temporary;
|
---|
| 276 |
|
---|
| 277 | ++ buffer;
|
---|
| 278 | -- tail;
|
---|
| 279 | }
|
---|
| 280 | }
|
---|
| 281 |
|
---|
| 282 |
|
---|
| 283 |
|
---|
| 284 | //---------------------------------------------
|
---|
| 285 |
|
---|
| 286 | #ifdef TESTSUITE
|
---|
| 287 | #include "base/coverage_undefs.h"
|
---|
| 288 |
|
---|
| 289 | #include <cctype>
|
---|
| 290 | #define _isprint(x) isprint(x)
|
---|
| 291 |
|
---|
| 292 | class TFileContainer : public FileContainer
|
---|
| 293 | {
|
---|
| 294 | public:
|
---|
| 295 | TFileContainer(void) throw() {}
|
---|
| 296 | virtual ~TFileContainer(void) throw() {}
|
---|
| 297 |
|
---|
| 298 | string module;
|
---|
| 299 | void attachModule(const std::string & _module) throw(Exception)
|
---|
| 300 | {
|
---|
| 301 | CHECKPOINT("attachModule");
|
---|
| 302 | module = _module;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
| 305 | void * dest;
|
---|
| 306 | address_t addr;
|
---|
| 307 | size_t sz;
|
---|
| 308 | void loadContents(void * _dest, address_t _addr, size_t _sz) throw(Exception)
|
---|
| 309 | {
|
---|
| 310 | CHECKPOINT("loadContents");
|
---|
| 311 | dest = _dest;
|
---|
| 312 | addr = _addr;
|
---|
| 313 | sz = _sz;
|
---|
| 314 | memset(_dest, ~0, _sz);
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | string symbol;
|
---|
| 318 | address_t getSymbolAddress(const std::string & _symbol) throw(Exception)
|
---|
| 319 | {
|
---|
| 320 | CHECKPOINT("getSymbolAddress");
|
---|
| 321 | symbol = _symbol;
|
---|
| 322 | return 1;
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | std::string getArchitecture(void) throw(Exception)
|
---|
| 326 | { return "TFileContainer"; }
|
---|
| 327 |
|
---|
| 328 | TESTSUITE_PROTOTYPE(main)
|
---|
| 329 | };
|
---|
| 330 |
|
---|
| 331 | TESTSUITE(main, TFileContainer)
|
---|
| 332 | {
|
---|
| 333 | PREDECESSOR("SingletonBase");
|
---|
| 334 | PREDECESSOR("RuntimeObjectTable");
|
---|
| 335 |
|
---|
| 336 | SingletonBase::ContextChain chain;
|
---|
| 337 | chain.saveContext<RuntimeObjectTable>();
|
---|
| 338 | chain.renewInstance();
|
---|
| 339 |
|
---|
| 340 | BEGIN_CASE("getInstance","getInstance") {
|
---|
| 341 | BEGIN_CASE("1","ä½ãç»é²ããã¦ããªãã¨ãã®getInstanceã§ä¾å¤") {
|
---|
| 342 | bool result = false;
|
---|
| 343 | try { FileContainer::getInstance(); } catch(Exception &) { result = true; }
|
---|
| 344 | if(!result)
|
---|
| 345 | TEST_FAIL;
|
---|
| 346 | } END_CASE;
|
---|
| 347 |
|
---|
| 348 | BEGIN_CASE("2","getInstanceã§ã¤ã³ã¹ã¿ã³ã¹ãè¿ã") {
|
---|
| 349 | TFileContainer fc;
|
---|
| 350 | FileContainer * instance;
|
---|
| 351 | bool result = true;
|
---|
| 352 | try { instance = FileContainer::getInstance(); } catch(...) { result = false; }
|
---|
| 353 | TEST_CASE("1","ä¾å¤ã¯ãããªã", result);
|
---|
| 354 | TEST_CASE("2","åå¾ã§ããã¤ã³ã¹ã¿ã³ã¹ãæ£ãã", instance == &fc);
|
---|
| 355 | } END_CASE;
|
---|
| 356 | } END_CASE;
|
---|
| 357 |
|
---|
| 358 | BEGIN_CASE("parse_uint","parse_uint") {
|
---|
| 359 | BEGIN_CASE("1","æ°åãåãåºãã") {
|
---|
| 360 | unsigned int dest;
|
---|
| 361 | char * src = "123";
|
---|
| 362 | char * result = parse_uint(src, &dest);
|
---|
| 363 |
|
---|
| 364 | TEST_CASE("1","resultãæå¾ã«æ¥ã¦ãã", result == src + 3);
|
---|
| 365 | TEST_CASE("2","å¤ã¯æ£ãã", dest == 123);
|
---|
| 366 | } END_CASE;
|
---|
| 367 |
|
---|
| 368 | BEGIN_CASE("2","æ°åã§ç¡ãæåãä¸ããã¨ããã©ã«ãå¤ãè¿ã") {
|
---|
| 369 | unsigned int dest;
|
---|
| 370 | char * src = "abc";
|
---|
| 371 | char * result = parse_uint(src, &dest, 1234567);
|
---|
| 372 |
|
---|
| 373 | TEST_CASE("1","resultã¯é²ãã§ããªã", result == src);
|
---|
| 374 | TEST_CASE("2","ããã©ã«ãå¤ãè¿ã", dest == 1234567);
|
---|
| 375 | } END_CASE;
|
---|
| 376 |
|
---|
| 377 | BEGIN_CASE("3","ããªãã¿ã§ã¨ã¾ã") {
|
---|
| 378 | unsigned int dest;
|
---|
| 379 | char * src = "321,123";
|
---|
| 380 | char * result = parse_uint(src, &dest);
|
---|
| 381 |
|
---|
| 382 | TEST_CASE("1","resultã¯é²ãã§ããªã", result == src + 3);
|
---|
| 383 | TEST_CASE("2","ããã©ã«ãå¤ãè¿ã", dest == 321);
|
---|
| 384 | } END_CASE;
|
---|
| 385 | } END_CASE;
|
---|
| 386 |
|
---|
| 387 | BEGIN_CASE("attachInfo","attachInfo") {
|
---|
| 388 | BEGIN_CASE("1","æ®éã«å¦çãããã") {
|
---|
| 389 | fstream file("dummy",ios::out);
|
---|
| 390 | file << "s_kernel_tinib_table,32,0\nstask_initialization_block::texrtn,4,28\n";
|
---|
| 391 | file.close();
|
---|
| 392 |
|
---|
| 393 | TFileContainer fc;
|
---|
| 394 |
|
---|
| 395 | bool result = true;
|
---|
| 396 | try { fc.attachInfo("dummy"); } catch(...) { result = false; }
|
---|
| 397 |
|
---|
| 398 | TEST_CASE("1","ä¾å¤ã¯ãããªã", result);
|
---|
| 399 |
|
---|
| 400 | map<string, struct tagVariableInfo>::iterator scope = fc.variableinfo.find("_kernel_tinib_table");
|
---|
| 401 | TEST_CASE("2","è¦ç´ ã追å ããã¦ãã (tinib)", scope != fc.variableinfo.end());
|
---|
| 402 | TEST_CASE("3","å¤ãæ£ãã (tinib)", scope->second.size == 32);
|
---|
| 403 |
|
---|
| 404 | scope = fc.variableinfo.find("task_initialization_block::texrtn");
|
---|
| 405 | TEST_CASE("4","è¦ç´ ã追å ããã¦ãã (texrtn)", scope != fc.variableinfo.end());
|
---|
| 406 | TEST_CASE("5","å¤ãæ£ãã (texrtn.size)", scope->second.size == 4);
|
---|
| 407 | TEST_CASE("6","å¤ãæ£ãã (texrtn.address)", scope->second.address == 28);
|
---|
| 408 | } END_CASE;
|
---|
| 409 | remove("dummy");
|
---|
| 410 |
|
---|
| 411 | BEGIN_CASE("2","èå¥æå 'd' ãç¡è¦ãã") {
|
---|
| 412 | fstream file("dummy",ios::out);
|
---|
| 413 | file << "ddummy,0\ndtask_initialization_block::texrtn,4,28\n";
|
---|
| 414 | file.close();
|
---|
| 415 |
|
---|
| 416 | TFileContainer fc;
|
---|
| 417 |
|
---|
| 418 | bool result = true;
|
---|
| 419 | try { fc.attachInfo("dummy"); } catch(...) { result = false; }
|
---|
| 420 |
|
---|
| 421 | TEST_CASE("1","ä¾å¤ã¯ãããªã", result);
|
---|
| 422 | TEST_CASE("2","è¦ç´ ã¯è¿½å ããã¦ããªã", fc.variableinfo.size() == 0);
|
---|
| 423 | } END_CASE;
|
---|
| 424 | remove("dummy");
|
---|
| 425 |
|
---|
| 426 | BEGIN_CASE("3","空è¡ãç¡è¦ã§ãã") {
|
---|
| 427 | fstream file("dummy",ios::out);
|
---|
| 428 | file << "s_kernel_tinib_table,32,0\n\nstask_initialization_block::texrtn,4,28\n";
|
---|
| 429 | file.close();
|
---|
| 430 |
|
---|
| 431 | TFileContainer fc;
|
---|
| 432 |
|
---|
| 433 | bool result = true;
|
---|
| 434 | try { fc.attachInfo("dummy"); } catch(...) { result = false; }
|
---|
| 435 |
|
---|
| 436 | TEST_CASE("1","ä¾å¤ã¯ãããªã", result);
|
---|
| 437 |
|
---|
| 438 | map<string, struct tagVariableInfo>::iterator scope = fc.variableinfo.find("_kernel_tinib_table");
|
---|
| 439 | TEST_CASE("2","è¦ç´ ã追å ããã¦ãã (tinib)", scope != fc.variableinfo.end());
|
---|
| 440 | TEST_CASE("3","å¤ãæ£ãã (tinib)", scope->second.size == 32);
|
---|
| 441 |
|
---|
| 442 | scope = fc.variableinfo.find("task_initialization_block::texrtn");
|
---|
| 443 | TEST_CASE("4","è¦ç´ ã追å ããã¦ãã (texrtn)", scope != fc.variableinfo.end());
|
---|
| 444 | TEST_CASE("5","å¤ãæ£ãã (texrtn.size)", scope->second.size == 4);
|
---|
| 445 | TEST_CASE("6","å¤ãæ£ãã (texrtn.address)", scope->second.address == 28);
|
---|
| 446 | } END_CASE;
|
---|
| 447 | remove("dummy");
|
---|
| 448 |
|
---|
| 449 | BEGIN_CASE("4","'s'ã¨'d'以å¤ãã¯ãã") {
|
---|
| 450 | char c;
|
---|
| 451 | char msg[2] = {0, 0};
|
---|
| 452 |
|
---|
| 453 | for(c=0;c<128;++c) {
|
---|
| 454 | if(isprint(c) && (c != 's' && c != 'd')) {
|
---|
| 455 | fstream file("dummy",ios::out);
|
---|
| 456 | file << c;
|
---|
| 457 | file << "dummy,0\n";
|
---|
| 458 | file.close();
|
---|
| 459 |
|
---|
| 460 | TFileContainer fc;
|
---|
| 461 |
|
---|
| 462 | bool result = false;
|
---|
| 463 | try { fc.attachInfo("dummy"); } catch(...) { result = true; }
|
---|
| 464 |
|
---|
| 465 | msg[0] = c;
|
---|
| 466 | TEST_CASE_("1","ä¾å¤ãããã", result, string(msg));
|
---|
| 467 | TEST_CASE_("2","è¦ç´ ã¯è¿½å ããã¦ããªã", fc.variableinfo.size() == 0, string(msg));
|
---|
| 468 | }
|
---|
| 469 | }
|
---|
| 470 | } END_CASE;
|
---|
| 471 | remove("dummy");
|
---|
| 472 | } END_CASE;
|
---|
| 473 |
|
---|
| 474 | chain.restoreContext();
|
---|
| 475 | }
|
---|
| 476 |
|
---|
| 477 | class TTargetVariable : public TargetVariable<int>
|
---|
| 478 | {
|
---|
| 479 | TESTSUITE_PROTOTYPE(main)
|
---|
| 480 |
|
---|
| 481 | /*
|
---|
| 482 | * ã³ã³ã¹ãã©ã¯ã¿ (TargetVariable<int>ã«åé)
|
---|
| 483 | */
|
---|
| 484 | inline TTargetVariable(FileContainer::address_t addr) throw()
|
---|
| 485 | : TargetVariable<int>(addr)
|
---|
| 486 | {}
|
---|
| 487 |
|
---|
| 488 | inline TTargetVariable(FileContainer::address_t addr, size_t sz) throw()
|
---|
| 489 | : TargetVariable<int>(addr, sz)
|
---|
| 490 | {}
|
---|
| 491 |
|
---|
| 492 | inline TTargetVariable(FileContainer::address_t addr, size_t sz, size_t ofs, size_t ssz) throw()
|
---|
| 493 | : TargetVariable<int>(addr, sz, ofs, ssz)
|
---|
| 494 | {}
|
---|
| 495 |
|
---|
| 496 | inline TTargetVariable(const std::string & sym) throw()
|
---|
| 497 | : TargetVariable<int>(sym)
|
---|
| 498 | {}
|
---|
| 499 |
|
---|
| 500 | inline TTargetVariable(const std::string & sym, const std::string & sz) throw()
|
---|
| 501 | : TargetVariable<int>(sym, sz)
|
---|
| 502 | {}
|
---|
| 503 |
|
---|
| 504 | /* ãã¹ãã©ã¯ã¿ (ç¹ã«ä½ãããªã) */
|
---|
| 505 | virtual ~TTargetVariable(void) throw()
|
---|
| 506 | {}
|
---|
| 507 | };
|
---|
| 508 |
|
---|
| 509 | TESTSUITE(main, TTargetVariable)
|
---|
| 510 | {
|
---|
| 511 | PREDECESSOR("SingletonBase");
|
---|
| 512 | PREDECESSOR("TFileContainer");
|
---|
| 513 | PREDECESSOR("RuntimeObjectTable");
|
---|
| 514 |
|
---|
| 515 | SingletonBase::ContextChain chain;
|
---|
| 516 | chain.saveContext<RuntimeObjectTable>();
|
---|
| 517 | chain.renewInstance();
|
---|
| 518 |
|
---|
| 519 | TFileContainer fc;
|
---|
| 520 | fstream file("dummy",ios::out);
|
---|
| 521 | file << "s_test,4,0\ns_kernel_tinib_table,32,0\nstask_initialization_block::texrtn,4,28\n";
|
---|
| 522 | file.close();
|
---|
| 523 |
|
---|
| 524 | fc.attachInfo("dummy");
|
---|
| 525 |
|
---|
| 526 | BEGIN_CASE("constructor","ã³ã³ã¹ãã©ã¯ã¿") {
|
---|
| 527 | BEGIN_CASE("1", "(address_t, size_t)") {
|
---|
| 528 | TTargetVariable tv(1, 2);
|
---|
| 529 |
|
---|
| 530 | TEST_CASE("1","å¤æ°ã¯æå¹", tv.isValid());
|
---|
| 531 | TEST_CASE("2","ã¢ãã¬ã¹ã¯æ£ãã", tv.getAddress() == 1);
|
---|
| 532 | TEST_CASE("3","ãµã¤ãºã¯æ£ãã", tv.getSize() == 2);
|
---|
| 533 | TEST_CASE("4","ãªãã»ããã¯0", tv.getOffset() == 0);
|
---|
| 534 | TEST_CASE("5","æ§é ä½ãµã¤ãºã¯å¤æ°ãµã¤ãºã¨ä¸ç·", tv.getStructureSize() == tv.getSize());
|
---|
| 535 | } END_CASE;
|
---|
| 536 |
|
---|
| 537 | BEGIN_CASE("2","(address_t, size_t, size_t, size_t)") {
|
---|
| 538 | TTargetVariable tv(1,2,3,4);
|
---|
| 539 |
|
---|
| 540 | TEST_CASE("1","å¤æ°ã¯æå¹", tv.isValid());
|
---|
| 541 | TEST_CASE("2","ã¢ãã¬ã¹ã¯æ£ãã", tv.getAddress() == 1);
|
---|
| 542 | TEST_CASE("3","ãµã¤ãºã¯æ£ãã", tv.getSize() == 2);
|
---|
| 543 | TEST_CASE("4","ãªãã»ããã¯æ£ãã", tv.getOffset() == 3);
|
---|
| 544 | TEST_CASE("5","æ§é ä½ãµã¤ãºã¯æ£ãã", tv.getStructureSize() == 4);
|
---|
| 545 | } END_CASE;
|
---|
| 546 |
|
---|
| 547 | BEGIN_CASE("3","(string)") {
|
---|
| 548 | TestSuite::clearCheckpoints();
|
---|
| 549 |
|
---|
| 550 | TTargetVariable tv("_test");
|
---|
| 551 |
|
---|
| 552 | TEST_CASE("1","å¤æ°ã¯æå¹", tv.isValid());
|
---|
| 553 | TEST_CASE("2","getSymbolAddressãã³ã¼ã«ããã¦ãã", TestSuite::isReached("getSymbolAddress"));
|
---|
| 554 | TEST_CASE("3","getSymbolAddressã®å¼æ°ãæ£ãã", fc.symbol.compare("_test") == 0);
|
---|
| 555 | TEST_CASE("3","ã¢ãã¬ã¹ã¯æ£ãã", tv.getAddress() == 1);
|
---|
| 556 | TEST_CASE("4","ãµã¤ãºã¯æ£ãã", tv.getSize() == 4);
|
---|
| 557 | TEST_CASE("5","ãªãã»ããã¯æ£ãã", tv.getOffset() == 0);
|
---|
| 558 | TEST_CASE("6","æ§é ä½ãµã¤ãºã¯æ£ãã", tv.getStructureSize() == 4);
|
---|
| 559 | } END_CASE;
|
---|
| 560 |
|
---|
| 561 | BEGIN_CASE("4","(string,string)") {
|
---|
| 562 | TestSuite::clearCheckpoints();
|
---|
| 563 |
|
---|
| 564 | TTargetVariable tv("_kernel_tinib_table", "task_initialization_block::texrtn");
|
---|
| 565 |
|
---|
| 566 | TEST_CASE("1","å¤æ°ã¯æå¹", tv.isValid());
|
---|
| 567 | TEST_CASE("2","getSymbolAddressãã³ã¼ã«ããã¦ãã", TestSuite::isReached("getSymbolAddress"));
|
---|
| 568 | TEST_CASE("3","getSymbolAddressã®å¼æ°ãæ£ãã", fc.symbol.compare("_kernel_tinib_table") == 0);
|
---|
| 569 | TEST_CASE("3","ã¢ãã¬ã¹ã¯æ£ãã", tv.getAddress() == 1);
|
---|
| 570 | TEST_CASE("4","ãµã¤ãºã¯æ£ãã", tv.getSize() == 4);
|
---|
| 571 | TEST_CASE("5","ãªãã»ããã¯æ£ãã", tv.getOffset() == 28);
|
---|
| 572 | TEST_CASE("6","æ§é ä½ãµã¤ãºã¯æ£ãã", tv.getStructureSize() == 32);
|
---|
| 573 | } END_CASE;
|
---|
| 574 |
|
---|
| 575 | BEGIN_CASE("5","ç¡å¹ãªã±ã¼ã¹") {
|
---|
| 576 | TEST_CASE("1","ã¢ãã¬ã¹0ã®å¤æ°ã¯ç¡å¹ (1)", !TTargetVariable(0,4).isValid());
|
---|
| 577 | TEST_CASE("2","ã¢ãã¬ã¹0ã®å¤æ°ã¯ç¡å¹ (2)", !TTargetVariable(0,4,4,4).isValid());
|
---|
| 578 | TEST_CASE("3","ãµã¤ãº0ã®å¤æ°ã¯ç¡å¹ (1)", !TTargetVariable(4,0).isValid());
|
---|
| 579 | TEST_CASE("4","ãµã¤ãº0ã®å¤æ°ã¯ç¡å¹ (2)", !TTargetVariable(4,0,4,4).isValid());
|
---|
| 580 | TEST_CASE("5","æ§é ä½ãµã¤ãº0ã®å¤æ°ã¯ç¡å¹", !TTargetVariable(4,4,4,0).isValid());
|
---|
| 581 |
|
---|
| 582 | TEST_CASE("6","åå¨ããªãã·ã³ãã«åã®å¤æ°ãç¡å¹(1)", !TTargetVariable("unknown").isValid());
|
---|
| 583 | TEST_CASE("7","åå¨ããªãã·ã³ãã«åã®å¤æ°ãç¡å¹(2)", !TTargetVariable("unknown","task_initialization_block::texrtn").isValid());
|
---|
| 584 | TEST_CASE("8","åå¨ããªãã¡ã³ãåã®å¤æ°ãç¡å¹", !TTargetVariable("_kernel_tinib_table","unknown").isValid());
|
---|
| 585 |
|
---|
| 586 | TEST_CASE("10","æ ¼ç´é åãä¸è¶³ãã¦ããå¤æ°", !TTargetVariable("_kernel_tinib_table").isValid());
|
---|
| 587 | TEST_CASE("11","ç¡å¹ãªå¼æ°ãããã£ãå ´å", !TTargetVariable(*((TTargetVariable *)0)).isValid());
|
---|
| 588 | } END_CASE;
|
---|
| 589 | } END_CASE;
|
---|
| 590 |
|
---|
| 591 | BEGIN_CASE("loadContents", "loadContents") {
|
---|
| 592 | BEGIN_CASE("1","é常起å") {
|
---|
| 593 | int i;
|
---|
| 594 | TTargetVariable tv(0x100);
|
---|
| 595 |
|
---|
| 596 | bool result = true;
|
---|
| 597 | try { tv.loadContent(&i, sizeof(int)); } catch(...) { result = false; }
|
---|
| 598 |
|
---|
| 599 | TEST_CASE("1","ä¾å¤ã¯èµ·ãããªã", result);
|
---|
| 600 | TEST_CASE("2","ä¸èº«ã¯~0ã§ãã£ã«ããã¦ãã", i == ~0);
|
---|
| 601 | } END_CASE;
|
---|
| 602 |
|
---|
| 603 | BEGIN_CASE("2","å
|
---|
| 604 | ããã大ããªåã§åãã") {
|
---|
| 605 | struct { int first; int second; } i;
|
---|
| 606 | TTargetVariable tv(0x100);
|
---|
| 607 |
|
---|
| 608 | bool result = true;
|
---|
| 609 | try { tv.loadContent(&i, sizeof(i)); } catch(...) { result = false; }
|
---|
| 610 |
|
---|
| 611 | TEST_CASE("1","ä¾å¤ã¯èµ·ãããªã", result);
|
---|
| 612 | TEST_CASE("2","ä¸èº«ã¯~0ã§ãã£ã«ããã¦ãã", i.first == ~0);
|
---|
| 613 | TEST_CASE("3","æ®ãã¯0ã§ãã£ã«ããã¦ãã", i.second == 0);
|
---|
| 614 | } END_CASE;
|
---|
| 615 |
|
---|
| 616 | BEGIN_CASE("3","ç¡å¹ãªè¦ç´ ã«å¯¾ãã¦å®è¡ãã") {
|
---|
| 617 | TTargetVariable tv(0, 0, 0, 0);
|
---|
| 618 | int i;
|
---|
| 619 |
|
---|
| 620 | bool result = false;
|
---|
| 621 | try{ tv.loadContent(&i, sizeof(i)); } catch(...) { result = true; }
|
---|
| 622 | TEST_CASE("1","ä¾å¤ãèµ·ãã", result);
|
---|
| 623 | } END_CASE;
|
---|
| 624 |
|
---|
| 625 | BEGIN_CASE("4","å
|
---|
| 626 | ãããå°ããªåã§åãã") {
|
---|
| 627 | char i;
|
---|
| 628 | TTargetVariable tv(0x100);
|
---|
| 629 |
|
---|
| 630 | bool result = false;
|
---|
| 631 | try { tv.loadContent(&i, sizeof(i)); } catch(...) { result = true; }
|
---|
| 632 |
|
---|
| 633 | TEST_CASE("1","ä¾å¤ãèµ·ãã", result);
|
---|
| 634 | } END_CASE;
|
---|
| 635 |
|
---|
| 636 | } END_CASE;
|
---|
| 637 |
|
---|
| 638 | BEGIN_CASE("pointer_operators","ãã¤ã³ã¿é¢¨ã®æ¼ç®") {
|
---|
| 639 | TargetVariable<int> tv(0x100);
|
---|
| 640 | TargetVariable<int> tvl(0x100);
|
---|
| 641 |
|
---|
| 642 | *tvl;
|
---|
| 643 |
|
---|
| 644 | TEST_CASE("0","[åæ] tv:ã¢ãã¬ã¹ã¯0x100", tv.getAddress() == 0x100);
|
---|
| 645 | TEST_CASE("0","[åæ] tv:ãµã¤ãºã¯4", tv.getSize() == 4);
|
---|
| 646 | TEST_CASE("0","[åæ] tv:æ§é ä½ãµã¤ãºã4", tv.getStructureSize() == 4);
|
---|
| 647 | TEST_CASE("0","[åæ] tv:èªåºãæªäº", !tv.isLoaded());
|
---|
| 648 | TEST_CASE("0","[åæ] tvl:ã¢ãã¬ã¹ã¯0x100", tvl.getAddress() == 0x100);
|
---|
| 649 | TEST_CASE("0","[åæ] tvl:ãµã¤ãºã¯4", tvl.getSize() == 4);
|
---|
| 650 | TEST_CASE("0","[åæ] tvl:æ§é ä½ãµã¤ãºã4", tvl.getStructureSize() == 4);
|
---|
| 651 | TEST_CASE("0","[åæ] tvl:èªåºãå®äº", tvl.isLoaded());
|
---|
| 652 |
|
---|
| 653 | BEGIN_CASE("1","operator +") {
|
---|
| 654 | TestSuite::clearCheckpoints();
|
---|
| 655 |
|
---|
| 656 | TargetVariable<int> work = tv + 0x10;
|
---|
| 657 | TEST_CASE("1","workã®ã¢ãã¬ã¹ã¯0x140", work.getAddress() == 0x100 + sizeof(int) * 0x10);
|
---|
| 658 | TEST_CASE("2","workã¯èªã¿è¾¼ã¾ãã¦ããªã", !work.isLoaded());
|
---|
| 659 | } END_CASE;
|
---|
| 660 |
|
---|
| 661 | BEGIN_CASE("2","operator -") {
|
---|
| 662 | TestSuite::clearCheckpoints();
|
---|
| 663 |
|
---|
| 664 | TargetVariable<int> work = tv - 0x10;
|
---|
| 665 | TEST_CASE("1","workã®ã¢ãã¬ã¹ã¯0xc0", work.getAddress() == 0x100 - sizeof(int) * 0x10);
|
---|
| 666 | TEST_CASE("2","workã¯èªã¿è¾¼ã¾ãã¦ããªã", !work.isLoaded());
|
---|
| 667 | } END_CASE;
|
---|
| 668 |
|
---|
| 669 | BEGIN_CASE("3","operator ++") {
|
---|
| 670 | TestSuite::clearCheckpoints();
|
---|
| 671 |
|
---|
| 672 | TargetVariable<int> work(tvl);
|
---|
| 673 |
|
---|
| 674 | TargetVariable<int> result = (++ work);
|
---|
| 675 |
|
---|
| 676 | TEST_CASE("1","workã®ã¢ãã¬ã¹ã¯0x104", work.getAddress() == 0x100 + sizeof(int));
|
---|
| 677 | TEST_CASE("2","work == result", work == result);
|
---|
| 678 | TEST_CASE("3","èªã¿è¾¼ã¿æªäºç¶æ
|
---|
| 679 | ", !result.isLoaded());
|
---|
| 680 | } END_CASE;
|
---|
| 681 |
|
---|
| 682 | BEGIN_CASE("4","operator ++(int)") {
|
---|
| 683 | TestSuite::clearCheckpoints();
|
---|
| 684 |
|
---|
| 685 | TargetVariable<int> work(tvl);
|
---|
| 686 |
|
---|
| 687 | TargetVariable<int> result = (work++);
|
---|
| 688 |
|
---|
| 689 | TEST_CASE("1","workã®ã¢ãã¬ã¹ã¯0x104", work.getAddress() == 0x100 + sizeof(int));
|
---|
| 690 | TEST_CASE("2","resultã®ã¢ãã¬ã¹ã¯0x100", result.getAddress() == 0x100);
|
---|
| 691 | TEST_CASE("3","èªã¿è¾¼ã¿å®äºç¶æ
|
---|
| 692 | ", result.isLoaded());
|
---|
| 693 | } END_CASE;
|
---|
| 694 |
|
---|
| 695 | BEGIN_CASE("5","operator --") {
|
---|
| 696 | TestSuite::clearCheckpoints();
|
---|
| 697 |
|
---|
| 698 | TargetVariable<int> work(tvl);
|
---|
| 699 |
|
---|
| 700 | TargetVariable<int> result = (-- work);
|
---|
| 701 |
|
---|
| 702 | TEST_CASE("1","workã®ã¢ãã¬ã¹ã¯0x9c", work.getAddress() == 0x100 - sizeof(int));
|
---|
| 703 | TEST_CASE("2","work == result", work == result);
|
---|
| 704 | TEST_CASE("3","èªã¿è¾¼ã¿æªäºç¶æ
|
---|
| 705 | ", !result.isLoaded());
|
---|
| 706 | } END_CASE;
|
---|
| 707 |
|
---|
| 708 | BEGIN_CASE("6","operator --(int)") {
|
---|
| 709 | TestSuite::clearCheckpoints();
|
---|
| 710 |
|
---|
| 711 | TargetVariable<int> work(tvl);
|
---|
| 712 |
|
---|
| 713 | TargetVariable<int> result = (work--);
|
---|
| 714 |
|
---|
| 715 | TEST_CASE("1","workã®ã¢ãã¬ã¹ã¯0x9c", work.getAddress() == 0x100 - sizeof(int));
|
---|
| 716 | TEST_CASE("2","resultã®ã¢ãã¬ã¹ã¯0x100", result.getAddress() == 0x100);
|
---|
| 717 | TEST_CASE("3","èªã¿è¾¼ã¿å®äºç¶æ
|
---|
| 718 | ", result.isLoaded());
|
---|
| 719 | } END_CASE;
|
---|
| 720 |
|
---|
| 721 | BEGIN_CASE("7","operator +=") {
|
---|
| 722 | TestSuite::clearCheckpoints();
|
---|
| 723 |
|
---|
| 724 | TargetVariable<int> work(tvl);
|
---|
| 725 |
|
---|
| 726 | work += 0x10;
|
---|
| 727 |
|
---|
| 728 | TEST_CASE("1","workã®ã¢ãã¬ã¹ã¯0x140", work.getAddress() == 0x100 + sizeof(int) * 0x10);
|
---|
| 729 | TEST_CASE("2","èªã¿è¾¼ã¿æªäºç¶æ
|
---|
| 730 | ", !work.isLoaded());
|
---|
| 731 | } END_CASE;
|
---|
| 732 |
|
---|
| 733 | BEGIN_CASE("8","operator -=") {
|
---|
| 734 | TestSuite::clearCheckpoints();
|
---|
| 735 |
|
---|
| 736 | TargetVariable<int> work(tvl);
|
---|
| 737 |
|
---|
| 738 | work -= 0x10;
|
---|
| 739 |
|
---|
| 740 | TEST_CASE("1","workã®ã¢ãã¬ã¹ã¯0xc0", work.getAddress() == 0x100 - sizeof(int) * 0x10);
|
---|
| 741 | TEST_CASE("2","èªã¿è¾¼ã¿æªäºç¶æ
|
---|
| 742 | ", !work.isLoaded());
|
---|
| 743 | } END_CASE;
|
---|
| 744 |
|
---|
| 745 | BEGIN_CASE("9", "operator &") {
|
---|
| 746 | TEST_CASE("1","ã¢ãã¬ã¹ãæãã", &tv == 0x100);
|
---|
| 747 | TEST_CASE("2","NULLã¤ã³ã¹ã¿ã³ã¹ã«ã¯0ãè¿ã", &(*((TargetVariable<int> *)0)) == 0);
|
---|
| 748 | } END_CASE;
|
---|
| 749 |
|
---|
| 750 | BEGIN_CASE("10", "operator *") {
|
---|
| 751 | TestSuite::clearCheckpoints();
|
---|
| 752 | TargetVariable<int> work(0x100);
|
---|
| 753 |
|
---|
| 754 | const void * result = &(*work);
|
---|
| 755 |
|
---|
| 756 | TEST_CASE("1","loadContentsãå®è¡ããã¦ãã", TestSuite::isReached("loadContents"));
|
---|
| 757 | TEST_CASE("2","å¼æ°ãæ£ãã", fc.addr == 0x100);
|
---|
| 758 | TEST_CASE("3","å¼æ°ãæ£ãã", fc.sz == sizeof(int));
|
---|
| 759 |
|
---|
| 760 | TestSuite::clearCheckpoints();
|
---|
| 761 | *work;
|
---|
| 762 |
|
---|
| 763 | TEST_CASE("4","loadContentsã¯å®è¡ãããªã", !TestSuite::isReached("loadContents"));
|
---|
| 764 | } END_CASE;
|
---|
| 765 |
|
---|
| 766 | BEGIN_CASE("11","operator ==/!=") {
|
---|
| 767 | TEST_CASE("1","ã¢ãã¬ã¹ãä¸è´ããã°OK", tv == TTargetVariable(tv.getAddress()));
|
---|
| 768 | TEST_CASE("2","NULLã¤ã³ã¹ã¿ã³ã¹ã¨ã®æ¯è¼ãã§ãã", tv != *((TTargetVariable *)0));
|
---|
| 769 | } END_CASE;
|
---|
| 770 |
|
---|
| 771 | BEGIN_CASE("cvr","ã«ãã¬ãã¸å¯¾ç") {
|
---|
| 772 |
|
---|
| 773 | (*((TTargetVariable *)0)) ++;
|
---|
| 774 |
|
---|
| 775 | } END_CASE;
|
---|
| 776 |
|
---|
| 777 | } END_CASE;
|
---|
| 778 |
|
---|
| 779 | chain.restoreContext();
|
---|
| 780 | }
|
---|
| 781 |
|
---|
| 782 |
|
---|
| 783 | #endif
|
---|
| 784 |
|
---|