LTP GCOV extension - code coverage report
Current view: directory - src/libstore - misc.cc
Test: app.info
Date: 2004-12-21 Instrumented lines: 39
Code covered: 82.1 % Executed lines: 32

       1                 : #include "normalise.hh"
       2                 : 
       3                 : 
       4                 : StoreExpr storeExprFromPath(const Path & path)
       5             215 : {
       6             215 :     assertStorePath(path);
       7             215 :     ensurePath(path);
       8             215 :     ATerm t = ATreadFromNamedFile(path.c_str());
       9             215 :     if (!t) throw Error(format("cannot read aterm from `%1%'") % path);
      10             215 :     return parseStoreExpr(t);
      11                 : }
      12                 : 
      13                 : 
      14                 : PathSet storeExprRoots(const Path & nePath)
      15               8 : {
      16               8 :     PathSet paths;
      17                 : 
      18               8 :     StoreExpr ne = storeExprFromPath(nePath);
      19                 : 
      20               8 :     if (ne.type == StoreExpr::neClosure)
      21               6 :         paths.insert(ne.closure.roots.begin(), ne.closure.roots.end());
      22               2 :     else if (ne.type == StoreExpr::neDerivation)
      23               2 :         paths.insert(ne.derivation.outputs.begin(),
      24                 :             ne.derivation.outputs.end());
      25               0 :     else abort();
      26                 : 
      27               8 :     return paths;
      28                 : }
      29                 : 
      30                 : 
      31                 : static void requisitesWorker(const Path & nePath,
      32                 :     bool includeExprs, bool includeSuccessors,
      33                 :     PathSet & paths, PathSet & doneSet)
      34               1 : {
      35               1 :     checkInterrupt();
      36                 :     
      37               1 :     if (doneSet.find(nePath) != doneSet.end()) return;
      38               1 :     doneSet.insert(nePath);
      39                 : 
      40               1 :     StoreExpr ne = storeExprFromPath(nePath);
      41                 : 
      42               1 :     if (ne.type == StoreExpr::neClosure)
      43               3 :         for (ClosureElems::iterator i = ne.closure.elems.begin();
      44                 :              i != ne.closure.elems.end(); ++i)
      45               2 :             paths.insert(i->first);
      46                 :     
      47               0 :     else if (ne.type == StoreExpr::neDerivation)
      48               0 :         for (PathSet::iterator i = ne.derivation.inputs.begin();
      49                 :              i != ne.derivation.inputs.end(); ++i)
      50               0 :             requisitesWorker(*i,
      51                 :                 includeExprs, includeSuccessors, paths, doneSet);
      52                 : 
      53               0 :     else abort();
      54                 : 
      55               1 :     if (includeExprs) paths.insert(nePath);
      56                 : 
      57               1 :     Path nfPath;
      58               1 :     if (includeSuccessors && querySuccessor(nePath, nfPath))
      59               0 :         requisitesWorker(nfPath, includeExprs, includeSuccessors,
      60                 :             paths, doneSet);
      61                 : }
      62                 : 
      63                 : 
      64                 : PathSet storeExprRequisites(const Path & nePath,
      65                 :     bool includeExprs, bool includeSuccessors)
      66               1 : {
      67               1 :     PathSet paths;
      68               1 :     PathSet doneSet;
      69               1 :     requisitesWorker(nePath, includeExprs, includeSuccessors,
      70                 :         paths, doneSet);
      71               1 :     return paths;
      72              51 : }

Generated by: LTP GCOV extension version 1.1