plainbox:session:resume: fix 1387782 (resume fails in certain cases)

This bug turned out to be an incorrect assumption in the way we
trim the job list as a part of the resume process. The specific case that
triggers this behavior is:

- desired job list: [a]
- run_list: (computed, not stored): [a_dep, a]
- results: []  # a_dep wasn't started yet

Before this patch, SessionState.trim_job_list() would raise ValueError
as the ResumeDiscardQualifier we're passing to it would try to remove
a_dep since it's not mentioned anywhere we were looking before.

With this patch, we're retaining two sets of jobs:
 - all the jobs from the run list, that's *everything* we have to run run
 - all the jobs that have results (just as a sanity check as it normally
   is a subset of the previous set)

The idea behind the trimming operation is that in applications that do
subset operations (checkbox-gui) where we pre-filter the full job list
based on some whitelist, after resuming we would see "more" jobs and that
was confusing/incorrect.

I think this property is still retained since the storage format doesn't
store qualifiers so we cannot give applications any chance to "select more"
than they would have as the selection is done in the app and that is done
after any subset operations. Since we still enforce the job is identical
constraint we cannot compute a different run list because of
new dependencies (except in cases where we haven't ran a job yet, that
is still possible, perhaps that's a separate bug).

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session:resume: run some tests on 4th resume format helper

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session:suspend: fix 1388055

This patch makes the 4th suspend helper more conservative in which
job checksums are included in the session (and thus checked at the time
we resume).

Assuming the following session state:

- desired_job_list: [a]
- run_list: [a_dep, a]
- results: []

We should save the representation of both a_dep and a to ensure they are
checked on resume

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
"automatic merge of lp:~zkrynicki/checkbox/fix-1388055/ by tarmac [r=kissiel][bug=1388055][author=zkrynicki]"
"automatic merge of lp:~zkrynicki/checkbox/fix-1387782/ by tarmac [r=kissiel][bug=1387782][author=zkrynicki]"