unit test

cppmock

gmock

exception

  • network exception, such as connection timeout, receive/send failure
    • connect refused
      • use exist IP, but port is not listened, then the connect operation will return error connect refused
      • hook connect function
      • iptables, iptables -t filter -p tcp -A OUTPUT -d DEST_IP --dport DEST_PORT -j REJECT --reject-with tcp-reset
    • connect timeout
    • read timeout
    • write timeout
    • disconnect when read/write
    • connect slowly
    • package dirty
  • memory exception, such as not enough memory, allocation failure
    • allocate fail
      • hook malloc function
  • disk exception, such as disk crash, not enough space
  • program exception

reference