  Tests of local realism and their applications aim for very high confidence in
their results even in the presence of potentially adversarial effects. For this
purpose, one can measure a quantity that reflects the amount of violation of
local realism and determine a bound on the probability, according to local
realism, of obtaining a violation at least that observed. In general, it is
difficult to obtain sufficiently robust and small bounds. Here we describe an
efficient protocol for computing such bounds from any set of Bell inequalities
for any number of parties, measurement settings, or outcomes. The protocol can
be applied to tests of other properties (such as entanglement or
dimensionality) that are witnessed by linear inequalities.
