Skip to content

Instantly share code, notes, and snippets.

@DevSecTim
DevSecTim / thread.cc
Created October 20, 2013 13:00
Minimal pthread wrapper classes, including the thread class itself and the mutex and lock_guard counterparts. Inherit from this class and override the thread_main pure virtual function to define the thread's entry point.
#include <cstring>
#include <sched.h>
#include <pthread.h>
#include "thread.h"
thread::thread() : _running(false)
{
}
@DevSecTim
DevSecTim / ForkedTest.cc
Created October 20, 2013 12:39
A method of using Posix fork to 'catch' and report seg faults in Google Test. To take advantage of it, use the ForkedTest class as your base test case class and remember to call its SetUp and TearDown in the derived classes' SetUp and TearDown.
#include <iostream>
#include <gtest/gtest.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <resource.h>
#include "ForkedTest.h"
@DevSecTim
DevSecTim / gtest_html_report.xsl
Created October 20, 2013 12:35
XSL transform to produce a human readable HTML page from Google Test XML output
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Google Test Report</title>
</head>
<body>
<table cellpadding="2" cellspacing="0" width="100%" border="1">