1
0

TestFramework.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef TestFramework_H
  16. #define TestFramework_H
  17. #include "net/Ducttape.h"
  18. #include "util/Linker.h"
  19. Linker_require("test/TestFramework.c")
  20. struct TestFramework
  21. {
  22. struct Allocator* alloc;
  23. struct Random* rand;
  24. struct EventBase* eventBase;
  25. struct Log* logger;
  26. struct SwitchCore* switchCore;
  27. struct Ducttape* ducttape;
  28. struct CryptoAuth* cryptoAuth;
  29. struct RouterModule* router;
  30. struct SwitchPinger* switchPinger;
  31. struct InterfaceController* ifController;
  32. /** The last message which this node sent. */
  33. struct Message* lastMsg;
  34. /**
  35. * A backup of the last message which this node sent.
  36. * Used to check if the framework alters the message after sending it.
  37. */
  38. struct Message* lastMsgBackup;
  39. uint8_t* publicKey;
  40. uint8_t* ip;
  41. Identity
  42. };
  43. #define TestFramework_KEY_SIZE 8
  44. struct TestFramework* TestFramework_setUp(char* privateKey,
  45. struct Allocator* allocator,
  46. struct Log* logger);
  47. void TestFramework_linkNodes(struct TestFramework* client, struct TestFramework* server);
  48. void TestFramework_craftIPHeader(struct Message* msg, uint8_t srcAddr[16], uint8_t destAddr[16]);
  49. /** Check if the last message sent was altered after having been sent. */
  50. void TestFramework_assertLastMessageUnaltered(struct TestFramework* tf);
  51. #endif