Exemplo n.º 1
0
    def remove_element(self, x):
        i = simsym.SInt.var()
        simsym.assume(simsym.exists(i, simsym.symand(self.elts.len() > i, self.elts[i] == x)))
        newElts = symtypes.tlist(simsym.SInt, APref).var()
        k = simsym.SInt.var()
        k = 0
        while k < self.elts.len():
            if k != i:
                newElts.append(elts[k])
            k = k + 1

        self.elts = newElts
Exemplo n.º 2
0
# The simplified rename model from the SOSP '13 paper

import simsym
import symtypes
import model
import errno

SymByte = simsym.tuninterpreted('SymByte')
SymInode = simsym.tstruct(data=symtypes.tlist(SymByte), nlink=simsym.SInt)
SymIMap = simsym.tmap(simsym.SInt, SymInode)
SymFilename = simsym.tuninterpreted('Filename')
SymDir = symtypes.tdict(SymFilename, simsym.SInt)


class Rename(simsym.tstruct(fname_to_inum=SymDir, inodes=SymIMap)):
    @model.methodwrap(src=SymFilename, dst=SymFilename)
    def rename(self, src, dst):
        if simsym.symnot(self.fname_to_inum.contains(src)):
            #return (-1, errno.ENOENT)
            return -1
        if src == dst:
            return 0
        if self.fname_to_inum.contains(dst):
            self.inodes[self.fname_to_inum[dst]].nlink -= 1
        self.fname_to_inum[dst] = self.fname_to_inum[src]
        del self.fname_to_inum[src]
        return 0


model_class = Rename
Exemplo n.º 3
0
# The simplified rename model from the SOSP '13 paper

import simsym
import symtypes
import model
import errno

SymByte     = simsym.tuninterpreted('SymByte')
SymInode    = simsym.tstruct(data  = symtypes.tlist(SymByte),
                             nlink = simsym.SInt)
SymIMap     = simsym.tmap(simsym.SInt, SymInode)
SymFilename = simsym.tuninterpreted('Filename')
SymDir      = symtypes.tdict(SymFilename, simsym.SInt)

class Rename(simsym.tstruct(
        fname_to_inum=SymDir,
        inodes=SymIMap)):

    @model.methodwrap(src=SymFilename, dst=SymFilename)
    def rename(self, src, dst):
        if simsym.symnot(self.fname_to_inum.contains(src)):
            #return (-1, errno.ENOENT)
            return -1
        if src == dst:
            return 0
        if self.fname_to_inum.contains(dst):
            self.inodes[self.fname_to_inum[dst]].nlink -= 1
        self.fname_to_inum[dst] = self.fname_to_inum[src]
        del self.fname_to_inum[src]
        return 0
Exemplo n.º 4
0
import simsym
import symtypes
import model

SEventList = symtypes.tlist(simsym.SInt)


class Tracker(simsym.tstruct(events=SEventList, forgot=simsym.SBool)):
    def _eq_internal(self, o):
        if type(self) != type(o):
            return NotImplemented
        return simsym.symand([
            self.forgot == o.forgot,
            simsym.symor([self.forgot, self.events == o.events])
        ])

    @model.methodwrap()
    def track(self):
        self.events.append(model.cur_thread())

    @model.methodwrap()
    def report(self):
        if self.forgot:
            return SEventList.var(_len=0)
        return self.events

    @model.methodwrap()
    def forget(self):
        self.forgot = True

Exemplo n.º 5
0
class SData(symtypes.tlist(SDataVal, lenType=SOffset)):
    def _declare_assumptions(self, assume):
        super(SData, self)._declare_assumptions(assume)
        assume(self._len <= 8)
Exemplo n.º 6
0
import simsym
import symtypes
import model

SEventList = symtypes.tlist(simsym.SInt)

class Tracker(simsym.tstruct(events=SEventList, forgot=simsym.SBool)):
    def _eq_internal(self, o):
        if type(self) != type(o):
            return NotImplemented
        return simsym.symand([self.forgot == o.forgot,
                              simsym.symor([self.forgot,
                                            self.events == o.events])])

    @model.methodwrap()
    def track(self):
        self.events.append(model.cur_thread())

    @model.methodwrap()
    def report(self):
        if self.forgot:
            return SEventList.var(_len = 0)
        return self.events

    @model.methodwrap()
    def forget(self):
        self.forgot = True

model_class = Tracker